【问题标题】:Export Excel Not Working in IPAD导出 Excel 在 IPAD 中不起作用
【发布时间】:2013-10-10 10:26:19
【问题描述】:

我正在 c# .net 中进行 Excel 导出。我正在使用以下代码,该代码在台式机和笔记本电脑上运行良好。

   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();

但是当我在 IPAD 中使用它时,我收到了类似的错误

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

以上代码是否不支持IPAD。

注意:我进行了很多搜索,但我至少找到了解决此问题的相关解决方案。在过去的 3 天里,我正在搜索..请帮助专家。

【问题讨论】:

    标签: excel ipad c#-4.0 export


    【解决方案1】:

    上面的代码会在 PC 中产生输出,但是,有一种格式警告,同样在 iPad 中出现问题。

    您可以使用 csv 代替 Excel,不会出错但仍会在 excel 中打开。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-22
      • 1970-01-01
      • 2015-10-28
      • 1970-01-01
      • 2012-10-09
      • 1970-01-01
      • 2016-08-29
      相关资源
      最近更新 更多