Click here to Skip to main content
16,018,394 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hello All,
Please help me out with this.

The objective is like this.
1.Open Excel file(Already Existing)
2.Write Data To it.
3.Save it and close it.

Step 1 is achieved using
Excel.Workbook CreateXLFile = StartExcel.Workbooks.Open(
FileName,
0,
true,
5,
"",
"",
true,
Excel.XlPlatform.xlWindows,
"\t",
false,
false,
0,
true,
1,
0);

Excel.Worksheet SelectXLSheet = (Microsoft.Office.Interop.Excel.Worksheet)CreateXLFile.ActiveSheet;


Step 2 is achieved using
SelectXLSheet.Cells[Cell, Row] = Data;


Step 3 is tried using workbook.save() method.
But this does not work.
Please help me out with how i can only save method to save file rather than use saveas method.
Posted
Comments
Basnta Padhi 20-Jul-11 2:07am    
After putting a try/catch around it, its throwing an exception "'File.xls' is read-only. To save a copy, click OK, then give the workbook a new name in the Save As dialog box."

1 solution

Put a try/catch block around it and a debug breakpoint inside the catch block. At that point, you'll probably find out why it "doesn't work".
 
Share this answer
 
Comments
Basnta Padhi 20-Jul-11 2:06am    
its throwing an exception "'File.xls' is read-only. To save a copy, click OK, then give the workbook a new name in the Save As dialog box."

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900