Free Support Forum - aspose.com

Error when saving

Hi Laurence,



I’ve been using aspose.cells v. 3.7.2.0 with no problems.

I’ve upgraded to v. 3.8.1.0.



Now, I receive the following error when performing this type of save method:

summaryWorkbook.Save(folderPath & “\File.xls”, FileFormatType.Excel2003)

“Number was less than the array’s lower bound in the first dimension. Parameter name: dstIndex”




Please try this attached fix.

If the problem still occurs, could you post your sample code here or send it to nanjing@aspose.com? Thank you.

I sent you an email with the subject, Error when saving.



Let me know if you would like to see more code.

Hi Laurence,

I’m sorry to tell you this but I started receiving this error again after upgrading to v3.9.1.0.

Please send your email again. I forget what’s your email account and cannot find your previous email.

Are you Michael Aparicio?

I used the following sample code to test your file and it works fine:

Workbook book = new Workbook();
book.Open("d:\\temp\\rmrmain.xls");

Worksheet sheet = book.Worksheets["HR Coeff"];
sheet.Cells.ClearContents(4, ExcelHelper.ColumnNameToIndex("A"), 5, ExcelHelper.ColumnNameToIndex("F"));


DataTable dt = new DataTable();
dt.TableName = "TableName";
dt.Columns.Add("ID", typeof(int));
dt.Columns.Add("Date", typeof(DateTime));
dt.Columns.Add("fieldName", typeof(string));

DataRow dr = dt.NewRow();
dr[0] = 1;
dr[1] = DateTime.Now;
dr[2] = "Hello world";

dt.Rows.Add(dr);

dr = dt.NewRow();
dr[0] = 2;
dr[1] = DateTime.FromOADate(12345);
dr[2] = "Test";

dt.Rows.Add(dr);

dr = dt.NewRow();
dr[0] = 3;
dr[1] = DateTime.FromOADate(2222.34);
dr[2] = "Laurence";

dt.Rows.Add(dr);
sheet.Cells.ImportDataTable(dt, false, 4, ExcelHelper.ColumnNameToIndex("A"), false);

book.Save("d:\\test\\abc.xls");

Could you give me more information about your problem? Could you please create a simple test case project to show this problem? Thank you very much.

yes, that is I.



i wish i could give you more information but the problem only occurs when performing the following save method:



summaryWorkbook.Save(folderPath & “\RMRMain.xls”, FileFormatType.Excel2003)


i would attach some code but i cannot seem to find an option to do so. i’ll email it to you.

I sent a debug version which will write log to disk when meeting errors. Please try it and send me the log file. Thank you.

hi laurence,



thank you for the attachment you sent earlier but now i have a new
problem when saving. In my development box, i have no problem creating
and saving a workbook. but when i deploy it, the workbooks fail to
save. I checked the permissions on the directories and they are all
correct. And so, to double check that it wasn’t the directory permissions, i
went back to v3.8 and everything works fine. On the production machine i’m running iis 6 with SSL enabled and asp.net 2.0.

What’s the error message? Have you rebuild your application with the new dll and deployed your new built application with the new dll?

i did rebuild the application with the new dll, along with deploying it.



there is no error message. all i get is an event entry in my event log stating an event error occured (event code 4011).


Where does this error happen, still in Save method? What happens if you use my debug version?

i will not be able to test this until about 13hrs from now. i’ll send you an email with the log.txt then.

thanks again for all of your help Laurence.

I corrected the error message you saw on the log file.

I’m still getting not able to save the file while i’m in the production box. I did what you asked, saved the workbook to a stream and then to the disk and it still will not save. I do not get any errors on the application just in the event log. I don’t understand why i can save a file with v3.8 but not with v3.9.

1. Please add some debug information in your program to check the problem.

2. If you save the workbook to a stream first then to the disk, could you figure out if the problem occurs on saving to stream or after that? If it occurs on saving to stream, it seems that Aspose.Cells tries to access some resource on your product server but it's forbidden. If problem occurs after that, it shows that your application don't have enough rights to write file on disk.

so it turns out that the problem wasn’t with the saving of the workbooks but when aspose attempting to write to the log file. after wrapping the save method in a try-catch block, i re-published and re-ran the application to which i got an event log entry stating that there werent sufficient priviledges to write to log.txt. after fixing that, everything works great.

thanks for all of your help laurence. i’m sorry i didn’t catch this earlier. it surely would have saved us a lot of forum posts and time.

Now are you using the dll which doesn't write log file? I think it's all fine now.

Feel free to contact us if you find any questions about our products.

yes, now i am using the one that does not write to the log file and everything is working great.

thanks again.