-
September 13th, 2010, 03:07 AM
#1
I cant save xls file
Hi,
thanks in advanced.
i have a problem to save xls file, I think it permission problem or something I dont know.
i get this error when i try to :
myExcelWorkbook.Close(true, null, null); // close and save !!!!!
The file could not be accessed. Try one of the following:
• Make sure the specified folder exists.
• Make sure the folder that contains the file is not read-only.
• Make sure the file name does not contain any of the following characters: < > ? [ ] : | or *
• Make sure the file/path name doesn't contain more than 218 characters.
can someone knows this issue???
-
September 13th, 2010, 03:12 AM
#2
Re: I cant save xls file
Originally Posted by nana2010
Hi,
thanks in advanced.
i have a problem to save xls file, I think it permission problem or something I dont know.
i get this error when i try to :
myExcelWorkbook.Close(true, null, null); // close and save !!!!!
The file could not be accessed. Try one of the following:
• Make sure the specified folder exists.
• Make sure the folder that contains the file is not read-only.
• Make sure the file name does not contain any of the following characters: < > ? [ ] : | or *
• Make sure the file/path name doesn't contain more than 218 characters.
can someone knows this issue???
this is my code:
Excel.Application myExcelApp;
Excel.Workbooks myExcelWorkbooks;
Excel.Workbook myExcelWorkbook;
object misValue = System.Reflection.Missing.Value;
myExcelApp = new Excel.ApplicationClass();
myExcelApp.Visible = false;
myExcelWorkbooks = myExcelApp.Workbooks;
String fileName = "C:\\excel\\data.xls";// \\ set this to your file you want
myExcelWorkbook = myExcelWorkbooks.Open(fileName, misValue, false, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue);
Excel.Worksheet myExcelWorksheet = (Excel.Worksheet)myExcelWorkbook.ActiveSheet;
String cellFormulaAsString = myExcelWorksheet.get_Range("A2", misValue).Formula.ToString();// \\ this puts the formula in Cell A2 or text depending whats in it in the string.
myExcelWorksheet.get_Range("C22", misValue).Formula = "New Value"; //\\ this changes the cell value in C2 to "New Value" }
myExcelWorkbook.Close(true, null, null);
myExcelApp.Quit();
-
September 14th, 2010, 01:53 AM
#3
Re: I cant save xls file
Also ensure that the file doesn't remain opened in the Excel.
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|