I am trying to open existing excel file by the following
Excel.Application myExcelApp = new Excel.Application(); //myExcelApp.Workbooks.Open(filename, 0, true, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing); string workbookPath = "f:/aspx/sindhu_scorpiochat/coastal.xls"; Excel.Workbook excelWorkbook = myExcelApp.Workbooks.Open(workbookPath, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false); foreach (Excel.Worksheet sheet in myExcelApp.Worksheets) { sheet.SaveAs(Path.Combine(Path.GetDirectoryName("coastal.xls"), sheet.Name) + "." + mode.ToLower(), Excel.XlFileFormat.xlCSV, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); } myExcelApp.Workbooks.Close(); myExcelApp.Quit();
but it shows the error like "no overload for method open takes 15 arguments "
for this line of Excel.Workbook excelWorkbook = myExcelApp.Workbooks.Open(workbookPath, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
how can i solve the problem pls tell me how to rectify it
thanks sindhu
|
| Author: Sornamuki 26 Dec 2008 | Member Level: Bronze | Rating: Points: 5 |
Hi,
Actually what you need to do whether you want to open an existing .xls file only to view/to do any other process with the file.
If you only need to view the file follow the code:
Create new .aspx and copy the following code in the page load event.
********************************************* string strFilePath = Request.QueryString["Path"].ToString(); Response.ContentType = "Application/Excel"; Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(strFilePath) + ".xls"); Response.ContentType = "application/Excel"; //Get the physical path to the file. //Write the file directly to the HTTP content output stream. Response.WriteFile(strFilePath); Response.End();
**********************************
from the file where you have the link to view the file point this new .aspx page with .aspx?Path=filepath.
Note:filepath is the exact path of the file where you have the file.
|