I have now figured out how to reproduce the problem. It occurs when I save the workbook object to a MemoryStream, then later try to save the workbook object to a disk file. When the disk file is opened in Excel, the cell comments render incorrectly.
Conversely, if I save the workbook object directly to disk, then open the file in Excel, the cell comments render correctly. As far as I can tell, the cell comments are the only Excel feature that are adversely affected by first saving to a stream.
To reproduce the problem, use the code below:
private void commentprob_Click( object sender, EventArgs e )
{
Workbook excel = new Workbook();
// Set column widths.
excel.Worksheets[0].Cells.SetColumnWidth( 0, 11 );
excel.Worksheets[0].Cells.SetColumnWidth( 1, 15 );
// Write content to cells.
excel.Worksheets[0].Cells[0, 0].PutValue( "Text A" );
excel.Worksheets[0].Cells[0, 1].PutValue( "Text B" );
// Write a cell comment.
int commentIndex = excel.Worksheets[0].Comments.Add( 0, 0 );
Comment comment = excel.Worksheets[0].Comments[commentIndex];
comment.WidthCM = 2.0;
comment.HeightCM = 2.0;
comment.Note = "hello";
// Save workbook to a memory stream.
System.IO.MemoryStream memStream = new System.IO.MemoryStream();
excel.Save( memStream, FileFormatType.Default );
// Further processing may be done here...
// Save workbook to a disk file.
excel.Open( memStream, FileFormatType.Default );
excel.Save( "c:\\aspose.xls", FileFormatType.Default );
}
Note also that if you make the column widths 11 each, the comment renders correctly. Any idea what's going on?
Thanks
Alan