Free Support Forum - aspose.com

Aspose Cells exception saving Excel 2007 xlsx files

Hi,

Below is an exception I get when calling Workbook.Save("test.xlsx", FileFormatType.Excel2007Xlsx, SaveType.OpenInExcel, this.Response); I'm using ASP.NET and writing the code in c#. Aspose.Cells.dll is version 4.8.2.0.

I've previously called Workbook.Open with the excel file being an xlsx file of 2007 format. If the file opened is not 2007 format, the save works fine. The xlsx file has a chart on sheet1 and data cells in sheet 2.

All the Best,

Rich



[ArgumentOutOfRangeException: Index and length must refer to a location within the string.
Parameter name: length]
System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy) +7493051
xabb58b8f2887ff8e.xbb82d008db095c0c.x90ba9cfb3c794a97(XmlTextWriter xbdfb620b7167944b, x7a84bb5831c19d42 xd9f58b067c82c962) +195
xabb58b8f2887ff8e.xbb82d008db095c0c.x560fbd2662be66b1(XmlTextWriter xbdfb620b7167944b, Title x37a96021dbbe3532) +115
xabb58b8f2887ff8e.xbb82d008db095c0c.xbc9d71eb0d192ce6(XmlTextWriter xbdfb620b7167944b, Title x37a96021dbbe3532) +84
xabb58b8f2887ff8e.xbb82d008db095c0c.xf30f94ec3f1ada09(XmlTextWriter xbdfb620b7167944b) +54
xabb58b8f2887ff8e.xbb82d008db095c0c.x6210059f049f0d48(XmlTextWriter xbdfb620b7167944b) +270
xabb58b8f2887ff8e.xb440dd60010e3cc4.xea5674e36a812ab0(x6fc54f8ba8aae1d4 xd9171314ec0b2957) +222
xabb58b8f2887ff8e.xb440dd60010e3cc4.xc228659948392f83(x6fc54f8ba8aae1d4 xd9171314ec0b2957) +98
xabb58b8f2887ff8e.xb440dd60010e3cc4.x6b3641eeb6a37b82() +83
xabb58b8f2887ff8e.xb440dd60010e3cc4.x6210059f049f0d48() +149
Aspose.Cells.Workbook.Save(Stream stream, FileFormatType fileFormatType) +986
Aspose.Cells.Workbook.Save(String fileName, SaveType saveType, FileFormatType fileFormatType, HttpResponse response) +788
Aspose.Cells.Workbook.Save(String fileName, FileFormatType fileFormatType, SaveType saveType, HttpResponse response) +17

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

Please share your sample code and template file (if any) to reproduce the issue. We will check it soon.

Thank You & Best Regards,

Hi Nausherwan,

Below is a sample page that causes the exception. The problem is with the line assigning the title of the y axis of the chart

workbook.Worksheets[0].Charts[0].ValueAxis.Title.Text = "Alerts";

If you use Replace instead it works fine. I've also attached the xlsx file that I use.

All the Best,

Rich

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Aspose.Cells;

namespace WebAsposeApplication
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

Aspose.Cells.License license = new Aspose.Cells.License();
license.SetLicense("Aspose.Cells.lic");

Workbook workbook = new Workbook();

workbook.Open(Server.MapPath(".") + "\\" + "Excel.2007.Alerts.xlsx", FileFormatType.Excel2007Xlsx);

// below causes the exception when workbook.Save called
//workbook.Worksheets[0].Charts[0].ValueAxis.Title.Text = "Alerts";

// this line works and is a workaround
workbook.Worksheets[0].Charts[0].ValueAxis.Title.Text.Replace("Seconds", "Alerts");

workbook.Save("Excel.2007.Alerts_1.xlsx", FileFormatType.Excel2007Xlsx, SaveType.OpenInBrowser, this.Response);

}
}
}

Hi,

Thanks for providing us the template file with sample code.

We found the issue after an initial test using your code and template file.

Your issue has been added to our internal issue tracking system with an issue id: CELLSNET-13422. We will figure it out soon and keep you updated about the issue.

Thank you.

Hi,

Please try the attached version. We have fixed your mentioned issue.

Thank you.

Hi Amjad,

This fixed the problem. Thanks for the prompt response.

All the Best,

Rich

The issues you have found earlier (filed as 13422) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.