Inserting rows and moving charts?

Oct 23, 2012 at 5:57 PM

Hi!  NPOI is working great for me so far.  I do have one issue that I haven't been able to solve yet, regarding inserting rows and chart behavior.

 

I am creating a dynamic report from a template .xls file.  At the bottom of one of my worksheets are some charts that reference data ranges in the same sheet.  In the middle, above the charts, is a section where I dynamically insert rows (using ShiftRows()/CreateRow()).  The problem is, the charts are not moved downwards when the rows are inserted, so that my charts end up sitting on top of the data.

 

Is there a way to move the charts?  I tried getting HSSFChart objects for each of the charts, but the ChartY values are always zero for each of the charts, and changing the value doesn't seem to do anything.  I may have missed something here.  Alternatively, is there a way to get ShiftRows() to move the charts automatically?  The latter solution would be the easiest I suppose, but I haven't been able to make it work yet.

 

Any suggestions are greatly appreciated!  Everything else about NPOI is working great!

Coordinator
Nov 9, 2012 at 6:18 PM

Thank you for using NPOI. You are not the first one to request chart operation feature. The team is considering including chart part. But it's not determined yet. HSSFChart is in alpha version though it's included in the release.

ShiftRows cannot do what you want because it never operates chart records even the chart would have been supported. For now, I have to say sorry for chart part. There is no workaround for that. The only way I'm think is that you may operate the internal chart records by yourself directly. But it's really hard to make sure everything works. NPOI looks easy to use because it hides the details of these internal operations and we test almost everything in unit test to make sure the quality.

Anyway, if time is enough, we may include the chart part in NPOI 2.0.

Nov 9, 2012 at 6:32 PM

Hi Tony,

We ended up moving the charts in the template above the data, so that we could insert rows without worrying about overlap.  So at least in my case, there was a workaround =)

Thanks for the response! NPOI worked out great for our project, and I'll definitely use it again if we have a similar project come up.  I look forward to chart support whenever that becomes available!