2017-12-30 87 views
1

로 자동 맞춤이 여기 내 코드 -방법 포맷하려면 엑셀 열이 나는 엑셀 gridview에 수출하고 C#을

 HttpContext.Current.Response.Clear(); 
     HttpContext.Current.Response.Buffer = true; 
     HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName)); 
     HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); 
     HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"; 
     HttpContext.Current.Response.Charset = ""; 

     HttpContext.Current.Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=windows-1250\">\n"); 


     HttpContext.Current.Response.Write("<html xmlns:o='urn:schemas-microsoft-com:office:office'\n" + 
     "xmlns:x='urn:schemas-microsoft-com:office:excel'\n" + 

     "xmlns='http://www.w3.org/TR/REC-html40'>\n" + 
     "<head>\n"); 

, 나는 열 자동 맞춤을 드릴 수 없습니다. Google에서 혼동스럽고 많은 검색을 시도했지만 문제가 남아 있습니다. 도움이 될 것입니다. 감사합니다

답변

0

불행히도 OpenXML은 가장 긴 필드의 너비를 계산하고 그 너비를 열에 저장하여 Excel에서 내부적으로 처리되는 AutoFit 속성을 지원하지 않습니다.

당신은 또한 Worksheet.Column(colIndex).AutoFitColumn() 구문을 사용하여 마음에 당신이 (EPPlusEPPlus.Core 스프링의 계산 폭의 모든 무거운 할 것입니다 더 강력한 도서관에서 볼 수 있었다.