This project has moved and is read-only. For the latest updates, please go here.

Code working only when i use a break point

Feb 20, 2014 at 10:50 AM
Edited Feb 20, 2014 at 11:43 AM
Hi everyone,

I am a new user of the EPPlus library.

I have problems with saving and accessing the Excel file.

the error occure on this part of the code :

this.xlSheet = this.package.Workbook.Worksheets[indexFeuille];
indexFeuille = 1

private ExcelWorksheet xlSheet;
private ExcelPackage package;


this.package = new ExcelPackage(new FileInfo(pathFin), new FileInfo(pathTemplate));

The Template file is a hug excel file with 23 worksheets, charts and links between worksheets.

I notice that when i set a break point and a thread.sleep(5000) before accessing the worksheet, the program work fine.

here is the error

length cannot be less than zero

" à System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)\r\n à System.String.Substring(Int32 startIndex, Int32 length)\r\n à OfficeOpenXml.ExcelAddressBase.SetWbWs(String address)\r\n à OfficeOpenXml.ExcelAddressBase.SetAddress(String address)\r\n à OfficeOpenXml.ExcelAddressBase..ctor(String address)\r\n à OfficeOpenXml.ExcelAddress..ctor(String address)\r\n à OfficeOpenXml.ExcelWorkbook.GetDefinedNames()\r\n à OfficeOpenXml.ExcelPackage.get_Workbook()\r\n à GEREMINE.DAO.ExcelDAL.EcrireDataTable(Int32 indexFeuille, Int32 ligneDepart, Int32 colDepart, Boolean afficherTitreColonnes, DataTable table) dans d:\DTM_IG_SVN\DTM_IG_2_test\App_Code\DAO\ExcelDAL.cs:ligne 141"

Thks for the help