Following your advice, I have now managed to write some data to the oleobject1.bin file.
I used the code shown below.
Originally, the file contained a worksheet with a diagram object and a table worksheet with some data that the diagram is based on.
After the code completes, the diagram object no longer exists in the file! It seems like the code has deleted the diagram object but I cannot see, where / why this happens.
Do you have any clue, why the code shown below removes the diagram object from the first worksheet?
----------------
using (Stream excelStream = binFile.OpenRead ())
{
// if the Excel file could be opened
if (excelStream != null)
{
// read the file content into a MemoryStream
Byte[] bytes = new byte[excelStream.Length];
excelStream.Read(bytes, 0, (int)excelStream.Length);
sourceMemoryStream = new MemoryStream(bytes);
}
}
// write the data from the placeholder DataTable to
// the cell range, provided together with the placeholder
if (sourceMemoryStream != null)
{
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();
workbook.LoadData(sourceMemoryStream);
workbook.Worksheets[chartData.WorksheetName].Cells.ImportDataTable(
chartData.Data, false, 1, 1, false);
targetMemoryStream = workbook.SaveToStream();
}
// open the Excel file in write mode
using (Stream excelStream = binFile.OpenWrite (true))
{
if (targetMemoryStream != null)
{
// write the modified workbook to the Excel file
targetMemoryStream.WriteTo(excelStream);
}
}