Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Mon Jul 07, 2014 1:32 pm

Hello,

We use an existing XLS-file as a template, which is dynamically updated through ASP.net.

In this template there is 1 worksheet with the data (Worksheets[0]), and several worksheets with Charts.

When we try to edit the existing Chart's name and DataRange, this does not work.

Code: Select all
var workbook = new Workbook();
workbook.LoadFromFile(Page.MapPath(@"./Excel/Template.xls"), true);

var sheet = workbook.Worksheets[0];

chrt = workbook.Worksheets[1].Charts[0];
chrt.ChartTitle = "This is the new title";
chrt.DataRange = sheet.Range[string.Format("R4C1:R21C14"), true];


Setting the ChartTitle sometimes throws a null-reference exception.

Can anyone please assist? Thank you very much,


Frans-Willem Post
GSD Automatisering

fwpost
 
Posts: 3
Joined: Fri Oct 18, 2013 6:12 am

Tue Jul 08, 2014 3:29 am

Hello,

Thanks for your feedback.
Please provide your template excel for testing. kindly note that please zip it before uploading or send it to our Email( support@e-iceblue.com).
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Jul 08, 2014 6:52 am

Thanks for your reply.

Solved the problem by comparing a working example and the generating code.

Then I changed
Code: Select all
workbook.LoadFromFile(Page.MapPath(@"./Excel/Template.xls"), true);

to
Code: Select all
workbook.LoadFromFile(Page.MapPath(@"./Excel/Template.xls"));


What does this boolean "PreserveMode" do? Where is it documented?

Thanks again,

Frans-Willem Post
GSD Automatisering

fwpost
 
Posts: 3
Joined: Fri Oct 18, 2013 6:12 am

Tue Jul 08, 2014 9:22 am

Hello,

Thanks for your fast reply.
This boolean "PreserveMode" indicates if the open book in read-only mode.
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.XLS