Free Support Forum - aspose.com

Aspose Cells OLE looses charts

Hi,

switching from Aspose Cells 2.10 to 2.1.1 I faced the issue, that embedded charts in the OLE container vanish, meaning, that the worksheet with the chart becomes empty, while the data sheet is still there.

The OLE is an excel chart, embedded in a 2003-style PPT, modified using Asposes Slides 2.1.0.

This happens, if I extract the OLE stream, load a workbook and save this workbook back to the stream. Nothing else. Any idea? I don’t want to stay with older versions, not at least for support reasons.

Jens

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

Thank you for considering Aspose.

Please try the attached latest version of Aspose.Cells. If you still face any problem, please share your sample code and template file here. We will check it soon.

Thank You & Best Regards,

Hi,

it’s still having the same problem.

Code is easy rebuild:

the object, that gets loaded, is a “Microsoft Office Excel Chart” OLE-object.



protected OleObjectFrame targetOleFrame = null;



public CellsEditor(OleObjectFrame oleFrame) {

targetOleFrame = oleFrame;

}



void openAndSave() {

byte[] oleData = targetOleFrame.getObjectData();

Workbook workbook = new Workbook();

try {

workbook.loadData(new ByteArrayInputStream(oleData));

} catch (IOException ex) {

Logger.getLogger(CellsEditor.class.getName()).log(Level.SEVERE, null, ex);

}

workbook.setCalculationMode(CalculationMode.AUTOMATIC);



Worksheets worksheets = workbook.getWorksheets();

Worksheet dataSheet = worksheets.getSheet(“Sheet1”);

if (dataSheet == null) {

dataSheet = worksheets.getSheet(0);

}

// here would come the work

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

try {

workbook.setCalculateBeforeSave(true);

workbook.save(byteArrayOutputStream);

} catch (IOException ex) {

Logger.getLogger(CellsEditor.class.getName()).log(Level.SEVERE, null, ex);

}



targetOleFrame.setObjectData(byteArrayOutputStream.toByteArray());



try {

byteArrayOutputStream.close();

} catch (IOException ex) {

Logger.getLogger(CellsEditor.class.getName()).log(Level.SEVERE, null, ex);

}

}



Jens



Hi Jens,

Please try Workbook.open() method instead of Workbook.loadData() method in your code.

For your information, the drawing objects and other settings/attributes would not be imported when you use Workbook.loadData() method.

Thank you.

Thanks.

I must have overseen that notice in the javadoc, regarding the methods. Or I just just the “stupid” shortcut of my IDE’s proposal, that matched the data type.

Whatever it was, since it worked in the previous version, I did not expect it to switch functionality.



The naming part “Data” in “loadData” now gets a special meaning. that was not obvious for me in the first place.



Jens