使用互操作保存Excel工作簿-问题 [英] Saving a Excel workbook using Interop- Problem

查看:78
本文介绍了使用互操作保存Excel工作簿-问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

保存工作簿时出现以下错误

HRESULT的异常:0x800A03EC

代码如下:

I am getting the following error while saving a workbook

Exception from HRESULT: 0x800A03EC

Code is as follows:

try
{
  string str_Path;
  str_Path = txtFile.Text;
 
  if (File.Exists(str_Path))
  {
    SetNewCurrentCulture();
    string strFile = Path.GetFileName(str_Path);
    Excel.Application xlApp;
    Excel.Workbook xlWorkBook;
    Excel.Worksheet xlWorkSheet;
    xlApp = new Excel.ApplicationClass();
    xlApp.DefaultFilePath = str_Path;
    xlWorkBook = xlApp.Workbooks.Open(str_Path, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
    xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
                    
    xlWorkBook.SaveAs(strFile, Excel.XlFileFormat.xlDBF4, Type.Missing, Type.Missing, Type.Missing,
      Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing,
      Type.Missing, Type.Missing);
                   
    MessageBox.Show("File converted successfully.File(dbf) in My Documents");
    ResetCurrentCulture();
  }
  else
  {
    MessageBox.Show("File Not exist");
  }
}
catch
{
  MessageBox.Show("Error in converting to dbf");
}



谁能给我解决方案或我在哪里做错了?



Can anyone give me solution or where i am doing wrong?

推荐答案

查看此线程:
See this thread: http://vbcity.com/forums/t/127307.aspx[^].

—SA


SA击败了我.顺便说一句,您应该在问题中提到完整的错误消息.无论如何,您都可以找到更多已解决的链接.

来自HRESULT的异常:0x800A03EC-Excel,.Net,SQL和Windows Server 2008 [ Office的服务器端自动化的注意事项 [
SA beat me it. BTW you should have mentioned full error message in your question. Anyway here you go for more solved links.

Exception from HRESULT: 0x800A03EC - Excel, .Net, SQL and Windows Server 2008[^]

Free attachment
Considerations for server-side Automation of Office[^]


这篇关于使用互操作保存Excel工作簿-问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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