C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

opening existing exce filel in asp.net


Posted Date: 26 Dec 2008      Posted By: sindhu      Member Level: Silver     Points: 1   Responses: 1



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





Responses

Author: Sornamuki    26 Dec 2008Member Level: BronzeRating: 2 out of 52 out of 5     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.



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : how to pass qry string in inline coding?
Previous : to shobhit rai-----------------sql server
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use