We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

NullReferenceException when setting Header/Footer in page setup

Hi,

I use v.6.0.17 and get NullReferenceException running the code below:

using (FileStream fstream = new FileStream(sourcePath, FileMode.Open))
{
Aspose.Cells.Workbook w= new Aspose.Cells.Workbook(fstream);
var pageSetup = w.Worksheets[0].PageSetup;

//This line causes NullReferenceException when setting either Header or Footer below
pageSetup.ClearHeaderFooter();

pageSetup.SetHeader(0, "Left Header");
pageSetup.SetFooter(0, "Left Footer");
}

I use .ClearHeaderFooter() to clear all the page setup settings and to set only required. If I comment out the method's call then no exception.


Thanks,
Leo

Hi,


Please try our latest fixed version: v7.0.2.2, if you still find the issue, give us your template Excel file here to reproduce the issue. We will check it soon.

Thanks

It's still reproducible. In my code sample I open a workbook from a file. But it can be reproduced with new Workbook() as well.

Thanks,

Leo

Hi,


Well, I think you may manually clear the headers and footers, see the sample code that works fine.

//You can manually set the footers/headers blank.
worksheet.PageSetup.SetHeader(0, “”);
worksheet.PageSetup.SetHeader(1, “”);
worksheet.PageSetup.SetHeader(2, “”);
//…Set footers to blank

And, we will look into the issue if we can figure it out soon.

Thank you.

Thanks for the workaround Sahi, I did almost the same thing.

We just need to deploy the fix to production which is always a complex procedure.
So I reported the issue so that others could avoid it)

Hi,


I have logged a ticket for the issue with an id: CELLSNET-40045. We will look into it soon.

Thank you.

Hi,


Please try the latest version/fix v7.0.2.4. your issue is fixed by the fixed version.

Thank you.

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


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