导出Excel引发错误 [英] Exporting Excel throwing error

查看:241
本文介绍了导出Excel引发错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在将一个excel文件导出到本地磁盘.当我试图隐藏excel工作表时,它抛出以下错误:

HRESULT的异常:0x800A03EC




I am exporting an excel file to my local disk. When I am trying to hide the excel work sheet, its throwing the following error :

Exception from HRESULT: 0x800A03EC


foreach (Excel.Worksheet ws in wb.Worksheets)
{
   if (ws.Name.StartsWith("Sheet"))
      ws.Visible = XlSheetVisibility.xlSheetVeryHidden; // -->here the error is throwing exactly
   else
      ws.Protect("Nu*1", m, m, m, m, m, m, m, m, m, m, m, m, m, m, m);
}



我也经历过谷歌,但没有得到解决方案.任何帮助将不胜感激

谢谢
Pradeep Anugu.



I have gone through google also but I didn''t get the solution. Any help would be appreciated

Thank you,
Pradeep Anugu.

推荐答案

在谷歌搜索大约3分钟后,您有两种可能.

1)我找到了一些引用,说您不能隐藏工作簿中的最后一张纸.我很难相信这一点,但再也没有让我感到惊讶的东西了.解决方法应该足够简单.使您的用户可见表在工作簿中的最后一个表.将隐藏的床单放在集合中的第一位.

2)您必须始终至少可见一张纸.如果您尝试隐藏最后一个可见的工作表,则会引发此错误.
After about 3 minutes of Googling, you have two possibilities.

1) I''ve found references that say you cannot hide the last sheet in the workbook. I find this hard to believe, but nothing surprises me anymore. The workaround should be simple enough. Keep your user visible sheet the last sheet in the workbook. Put your hidden sheets first in the collection.

2) You must have at least one sheet visible at all times. If you try to hide the last visible sheet, this error will throw.


这篇关于导出Excel引发错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆