Excel工作表中的问题 [英] Problems in excel worksheet

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

问题描述



我在我的项目中使用excel应用程序.我将excel模板保存在一个文件夹中,文件的扩展名为.xlsm(带有宏).当我单击按钮时,将填充数据库中可用的数据,并且将具有相同扩展名的相同excel保存在不同的文件夹中,它在Microsoft Office 2007中都可以正常工作,但是在2003格式下不起作用,会引发错误.谁能帮我解决这个问题.这是代码:


Hi,

I am using the excel application in my project. I will save the excel template in one folder, the extension of the file is .xlsm(with macros). When I click the button the datas that are available in database will be filled and I am saving the same excel with the same extension in different folder its all working fine in microsoft office 2007, but its not working in 2003 format it throws an error. Can any one help me to solve this problem. Here is the code:


protected void btnExcelDownload_Click(object sender, EventArgs e)
   {
       try
       {

           excelApp = new Excel.ApplicationClass();  // Creates a new Excel Application
           excelApp.Visible = false;  // Makes Excel visible to the user.
           // The following code opens an existing workbook
           string workbookPath =Server.MapPath("~/Format/RiTE_Template.xlsm");
           //string workbookPath = Server.MapPath(Request.ApplicationPath) + @"\Format\RiTE_Template.xlsm";  // Add your own path here
           excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true,
               false, 0, true, false, false);
           // The following gets the Worksheets collection
           excelSheets = excelWorkbook.Worksheets;
          if ()
           {
              //here I am filling the excel worksheets
           }

               string filename = "Rite File" + "_" + SessionVarriables.BidIdSession + "_" + SessionVarriables.RevisionNumberSession;
               excelWorkbook.SaveAs(Server.MapPath("~/RiteFile/") + filename + ".xlsm");
               string path = Server.MapPath("~/RiteFile/") + filename + ".xlsm";
               excelApp.DisplayAlerts = false;
               excelApp.UserControl = false;
               excelWorkbook.Close();
               excelApp.Workbooks.Close();
               excelApp.Quit();
               System.Runtime.InteropServices.Marshal.ReleaseComObject(excelWorkbook);
               System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
               excelWorkbook = null;
               excelApp = null;
               System.Diagnostics.Process.Start(path);
           }
       }
       catch (Exception ex)
       {

           excelApp.DisplayAlerts = false;
           excelApp.UserControl = false;
           excelApp.Workbooks.Close();
           excelApp.Quit();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);
           excelApp = null;

       }


在Advance中致谢<</xml>


Thanks in Advance<</xml>

推荐答案

xlsx在excel 2003中默认不受支持.请查看更新链接:
http://support.microsoft.com/kb/924074 [ http://office. microsoft.com/en-us/support/microsoft-office-compatibility-pack-for-word-excel-and-powerpoint-HA010168676.aspx [
xlsx isn''t supported by default in excel 2003. Check the link for the update:
http://support.microsoft.com/kb/924074[^]

http://office.microsoft.com/en-us/support/microsoft-office-compatibility-pack-for-word-excel-and-powerpoint-HA010168676.aspx[^]

Good luck!


.xlsm是Excel 2007启用宏的电子表格文件,不支持excel 2003
.xlsm are Excel 2007 Macro-Enabled Spreadsheet files and not supprted to excel 2003


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

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