We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Error opening Excel file

When I try to open an Excel file with a path like this:

S:\data\2006\10-16-06 data 2.xls

I get an exception below. Are dash or space illegal characters?

--------------------------------------------
ex.ToString() "System.ArgumentException: Illegal characters in path.\r at System.IO.Path.CheckInvalidPathChars(String path)\r at System.IO.Path.GetFileName(String path)\r at Syncfusion.XlsIO.Implementation.ExternWorkbookImpl.InitShortName()\r at Syncfusion.XlsIO.Implementation.ExternWorkbookImpl.Parse(BiffReader reader)\r at Syncfusion.XlsIO.Implementation.Collections.ExternBookCollection.Parse(BiffReader reader)\r at Syncfusion.XlsIO.Implementation.WorkbookImpl.Parse(BiffReader reader, ExcelParseOptions options)\r at Syncfusion.XlsIO.Implementation.WorkbookImpl..ctor(IApplication application, Object parent, Stream stream, ExcelParseOptions options)\r at Syncfusion.XlsIO.Implementation.ApplicationImpl.CreateWorkbook(Object parent, Stream stream, ExcelParseOptions options)\r at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.OpenReadOnly(String strFileName, ExcelParseOptions options)\r at Syncfusion.XlsIO.Implementation.Collections.WorkbooksCollection.OpenReadOnly(String strFileName)\r at ReadStaticPositions.Form1.ReadPositions() in c:\\projects\\ReadStaticPositions\\ReadStaticPositions\\Form1.cs:line 58" string


-----------------------------------------------
Here''s the C# code:

ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;

string fp = StaticPath();
if( !File.Exists(fp) )
MessageBox.Show("Can''t find file" + fp);

IWorkbook workbook = application.Workbooks.OpenReadOnly(fp);
IWorksheet sheet = workbook.Worksheets[0];

MessageBox.Show(sheet.Range["A10"].Text);

excelEngine.ThrowNotSavedOnDestroy = false;
excelEngine.Dispose();

1 Reply

MW Melba Winshia Syncfusion Team October 11, 2006 10:13 AM UTC

Hi Doug,

I am afraid. I was unable to reproduce the issue. I used the following test sample to test your issue.

Sample :
Patherror.zip


Would it be possible to provide me your sample xls file in which you are able to reproduce the issue? It will help me in investigating further on this issue.

Thanks,
Melba




Loader.
Live Chat Icon For mobile
Up arrow icon