2013-10-10 2 views
0

엑셀 내보내기에서 C# .net으로 작업하고 있습니다. 데스크톱 및 랩톱에서 잘 작동하는 아래 코드를 사용하고 있습니다. 내가 IPAD이를 사용할 때엑셀 내보내기가 IPAD에서 작동하지 않습니다.

homeServices = new HomeServices(); 
    string htmlOutput = ""; 
    HttpContext.Current.Response.Clear(); 
    HttpContext.Current.Response.ClearContent(); 
    HttpContext.Current.Response.ClearHeaders(); 
    HttpContext.Current.Response.Buffer = true; 
    HttpContext.Current.Response.ContentType = "application/ms-excel"; 
    HttpContext.Current.Response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">"); 
    HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=Export.xls"); 
    HttpContext.Current.Response.Charset = "utf-8"; 
    HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250"); 

    htmlOutput = homeServices.ExportHomeData(); 
    HttpContext.Current.Response.Write(htmlOutput); 
    HttpContext.Current.Response.Flush(); 
    HttpContext.Current.Response.End(); 

그러나, 나는 위의 코드는 늘 아이 패드를 지원 여부

Unable to Read Document. An error occurred while reading the document. 

같은 오류를 얻고있다.

참고 : 필자는 많은 부분을 검색 했으므로이 문제와 관련된 해결책을 찾지 못했습니다. 지난 3 일 동안 나는 찾고 있습니다. 친절하게 도와주세요 전문가.

답변

0

위의 코드는 PC에서 출력을 생성하지만 하나의 형식 경고와 함께 IPad에서도 동일한 문제가 발생합니다.

Excel 대신 csv를 사용할 수 있지만 오류는 발생하지 않지만 여전히 Excel에서 열립니다.

HttpContext.Current.Response.AppendHeader ("Content-Type", "application/CSV"); HttpContext.Current.Response.AppendHeader ("Content-disposition", "attachment; filename ="+ fileName + ".CSV");

관련 문제