无法从Intranet上的客户端计算机打开ms-excel表

时间:2013-08-08 09:17:35

标签: c# asp.net excel

我使用c#创建了一个asp.net网站。单击该按钮时,网页中的值将存储到系统中的Excel工作表中。

这在本地完成时工作正常,但是当从客户端计算机访问时,在Intranet中,它显示错误说:

"file path is invalid or the file is already open"

如何打开Excel工作表并将数据保存在客户端计算机中?

我的代码:

Excel._Application myExcelApp;

Excel.Workbooks myExcelWorkbooks;

Excel.Workbook myExcelWorkbook;

// Excel ._Worksheet myExccelWorksheetToChange;

object misValue = System.Reflection.Missing.Value;

myExcelApp = new Excel.Application();

myExcelApp.Visible = true;

myExcelWorkbooks = myExcelApp.Workbooks;

String fileName = "D:\\marks.xlsx";

myExcelWorkbook = myExcelWorkbooks.Open(fileName, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false, 0, true);

   //  string name = System.IO.Path.GetTempPath()+Guid.NewGuid().ToString()+".xlsx";
    Excel.Worksheet myExcelWorksheet = (Excel.Worksheet)myExcelWorkbook.ActiveSheet;
 //   myExcelWorksheet.SaveAs("marks");

String cellFormulaAsString = myExcelWorksheet.get_Range("A2", misValue).Formula.ToString();

 myExcelWorksheet.get_Range("A1", misValue).Formula = TextBox1.Text;

0 个答案:

没有答案