Search code examples
javaexcelapache-poiexport-to-excel

Create Excel Chart within Excel File


I am exporting some data from my system. I want to visualize these datasets in an excel chart. I have found and old, closed question, where the solution was missing. The charts should redraw when i change a datafield, this is excel standard, i guess.

I think it may work this way:

  • export Data
  • create manually a chart with MS-Excel
  • save and load this as a template in all other future exports

Do you know how to do it with POI using Java? Especially the import of the chart as template?


Solution

  • Till now as the apache POI limitation is saying "You can not currently create charts. You can however create a chart in Excel, modify the chart data values using HSSF and write a new spreadsheet out. This is possible because POI attempts to keep existing records intact as far as possible".

    However in my case, I have created a chart manually on excel sheet using Named Ranges, and using java, I am updating named ranges as per my requirement. Since the chart is based on named ranges so it also get updated.

    For updation please check here