也许,你可能会不小心创建对象工作表,也可以对象工作表模板文件中已经存在。
无论如何,请尝试下面的示例代码,看看你会得到什么结果。它应该工作正常,没有任何问题。
如果工作正常,您可以根据此代码修改您的代码。
对于XLS格式保存,请使用XlsSaveOptions
和
对于XLSX格式保存,请使用OoxmlSaveOptions
示例代码在C#
//Create a new workbook
Workbook workbook = new Workbook();
//Get the first worksheet in the workbook
Worksheet sheet = workbook.Worksheets[0];
//Rest of your code goes here
string yourFileFormat = "XLS";
//Save file and send to client browser using selected format
if (yourFileFormat == "XLS")
{
workbook.Save(HttpContext.Current.Response, "output.xls", ContentDisposition.Attachment, new XlsSaveOptions(SaveFormat.Excel97To2003));
}
else
{
workbook.Save(HttpContext.Current.Response, "output.xlsx", ContentDisposition.Attachment, new OoxmlSaveOptions(SaveFormat.Xlsx));
}
HttpContext.Current.Response.End();
你显然是在工作k为Aspose。我更喜欢和遇到过同样问题的人谈话。谢谢。 – user426364