I have a spreadsheet which contains a chart. The chart data is mapped to a range of cells which are empty. From within my application I create a copy of the spreadsheet and then populate the range of cells. When I open the spreadsheet the data is there but the chart is empty. Is this not a correct approach to displaying a chart in Excel?
I have read several posts about using UltraChart and saving that as a bitmap and writing that to Excel but that seems an awfully long-winded approach.
Thanks
Just to make sure I understand correctly: you have an Excel file which already contains a chart mapped to a range of data. By using the Infragistics Excel library, you are loading the file, populating the range with data, and then saving out again? I believe this should work. If it is not, I will put you in contact with Developer Support so this issue can be investigated,
Thanks for the reply. Yes, that is exactly the case. I have an xls (created in 2007 but saved in 97/2003 format). In that spreadsheet I have a rectangular range of cells containing to which I map a simple column chart. If I type numbers in the cells columns immediately appear in the chart.
In code I make a copy of this file, and then use WorkBook.Load to open the copy. I select the worksheet from the worksheets collection then write data to the cells from a DataRow using:
object oVal = oRow[ iCol ]; oWorkSheet.GetCell( CellAddress ).Value = oVal;
where CellAddress is a string containing values like "B21" etc.
Then I save the spreadsheet using WorkSheet.Save.
When I double-click on the spreadsheet I get a warning saying that Office has detected a problem and that the file is probably dangerous. When the spreadsheet opens I can see all the data in the correct place. The chart is still there but it is empty. Interestingly, if I type values directly into the cells, columns do not appear in the chart. It seems as if the chart has lost its association with the cell range.
I am using v 10.2 of your libraries.
Should this work or am I taking the wrong approach?
Well I wasn't suggesting you update to 12.1 just yet. I just want to know if this issue has been addressed yet, but I will answer your questions anyway:
To attach the Excel sheet, reply to the post, click on the Options tab and click "Add/Update".
Hi Mike
I have installed 12.1 and rebuilt the application and I still get the same problem.
I have attached the spreadhseet. The worksheet I am using is called "KPI PPM 3 - High Risk"
Thanks for providing the file. I am getting the same results here with the latest code. Looks like the issue still exists. I have forwarded this post to the Developer Support Manager and a DS engineer will be contacting you about this issue.
Thanks very much for your help.
I have done a bit of further digging and discovered:
a. If I use a spreadsheet actually created in Excel 97-2003 (rather than 2007 and saved in 97-2003 format) AND do not write any data, then when I open the spreadsheet after calling oWorkbook.Save() I do not get an error message from Office but the graph has lost its mapping to the cells.
b. If I use the Excel 97-2003 spreadsheet above and just make a single write with:
oWorkSheet.GetCell( "C21" ).Value = 10
The spreadsheet goes crazy! Formatting has changed on all cells in the range mapped to the chart, rotated text has changed back to horizontal. Have a look at Row 1 and row 20.
Thanks for your help
Graham,
This issue has been submitted to our development team for further review. The reference number for this item is 118188. A support case has also been opened for you. The number for the support case is CAS-97068-FSD2VG. I will leave this case open and update you with any new information after the review. You can also continue to send updates to this case at any time. Please let me know if you need more information.