Free Support Forum - aspose.com

Exce.save returns - Object reference not set to an instance of an object

I'm a new user, beware.

I have an excel document that I would like to populate with data, it's reasonably complex (charts), if I execute the following lines on save I get the error message "Object reference not set...".

Dim _excel As Excel = New Excel

Dim _worksheet As Worksheet

_excel.Open("C:\temp\test.xls")

_excel.Save("C:\temp\test3.xls", FileFormatType.Excel2003)

If I execute the above on a blank 'test.xls' file everything is fine. Attached is the file that causes the problem.

Regards

Mark

I tried your code but didn’t find any problem. Which version of Aspose.Excel are you using? Please download v3.5.1 at www.aspose.com/downloads.

Strange, I just installed 3.5.1 but still have the same problem.

I've found the problem.... Hopefully there is a work around.

If a charts 'Location' is 'As new sheet' it does not work.

If a charts 'Location' is 'As object in' it works.

Is this behaviour you can see and therefore something needs to be done to get this to work?

I tested with your test.xls without any problem. Please make sure if you did use the new dll. Please remove the reference to Aspose.Excel in your project and re-add the reference to Aspose.Excel.dll v3.5.1.

The attached file is created with your sample code.

Laurence thank you for looking into this.

I have been trying with V3.5.1, I had removed the
old version and placed the new version into the references (the version displayed is V3.5.1.0). This is
running on Windows 2000 Professional with Visual Studio 2003 (Framework 1.1). Below is the inner exception, no matter
how I do this I can not get an excel document with a chart where the location is "As new sheet" to work. I also have
installed "Office 2003".The below is the exception staqce using the designer now.

-
Object reference not set to an instance of an object.
Void ?(Aspose.Excel.RW.?)
at Aspose.Excel.Worksheet.?(? ?)
at Aspose.Excel.Worksheets.?(? ?)
at Aspose.Excel.Worksheets.?(FileFormatType ?)
at Aspose.Excel.Worksheets.?(String ?, SaveType ?, FileFormatType ?, HttpResponse ?)
at Aspose.Excel.Excel.Save(String fileName, FileFormatType fileFormatType)
at Aspose.Excel.ExcelDesigner.Save(String resultSpreadsheet, FileFormatType fileFormatType)
at TMReporting.test.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\TMV32\General\test.aspx.vb:line 62

Failed to get this value
Aspose.Excel

This is a trail version, would that make any difference? Note: This is the only piece I need to get working to move ahead with the purchase.


Regards
Mark

p.s. Other than the above, this has been a breeze to work with.

Hi Mark,

Do you use the exact code as you mentioned with test.xls you post here? Could you please zip and post your sample project and template file here? I will check it ASAP.

I have had the same problem.

The problem is when a chart is its own sheet and not an object on a normal worksheet.

I really hope we can get a hotfix for asap as I am developing a solution that uses lots of charts as sheets for the display of the data.

Michael Irving

I fixed this bug. Please try this attached fix.

I just downloaded it and appreciate the fast response.Big Smile [:D]Geeked [8-|]

But as I installed aspose.excel with the installer and have it in the GAC etc. How do I upgrade the file?

Michael Irving

If you have installed Aspose.Excel with the installer and deploy it in the GAC, please change it in in .NET configuration. Or you just need to remove the reference to old Aspose.Excel.dll and re-add reference to the new dll.

Laurence wrote:

If you have installed Aspose.Excel with the installer and deploy it in the GAC, please change it in in .NET configuration. Or you just need to remove the reference to old Aspose.Excel.dll and re-add reference to the new dll.

And more specificly. How do I do this? To get the old version out of the gac and get the new version in?

Yes. That's the simplest way.

The problem is… I dont know how to add and remove assemblies from the GAC.

Just copy the new dll to your installed path, such as C:\Program Files\Aspose\Aspose.Excel\Bin .

Thanks for the fix. Works perfectly now.