打开Excel的问题 [英] Problem in opening an excel
问题描述
我试图打开excel表...但是这段代码不能用...
string path = Session [dir]。ToString( )+\\+ e.CommandArgument.ToString();
\\ path = E:\\PO \\ 1.xls
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing .Value;
xlApp = new Excel.ApplicationClass();
xlWorkBook = xl
App.Workbooks.Open(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.Close(true,misValue,misValue);
xlApp.Quit();
releaseObject(xlWorkSheet);
releaseObject(xlWorkBook);
releaseObject(xlApp);
I tried to open an excel sheet... but this code is not working ...
string path = Session["dir"].ToString() + "\\" + e.CommandArgument.ToString();
\\path = E:\\PO\\1.xls
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.ApplicationClass();
xlWorkBook = xlApp.Workbooks.Open(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.Close(true, misValue, misValue);
xlApp.Quit();
releaseObject(xlWorkSheet);
releaseObject(xlWorkBook);
releaseObject(xlApp);
推荐答案
我认为你需要复习如何在C#.net 中打开Excel XLS文件[ ^ ],这将对您有所帮助。
Hi,
I think you need to review How to open Excel XLS file in C#.net[^], this will help you.
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName =EXCEL.EXE;
startInfo.Arguments = System.IO.Path.Combine(Session [dir]。ToString(),e.CommandArgument.ToString ());
Process.Start(startInfo);
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "EXCEL.EXE";
startInfo.Arguments = System.IO.Path.Combine(Session["dir"].ToString(), e.CommandArgument.ToString());
Process.Start(startInfo);
这篇关于打开Excel的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!