Category formula is invalid

  • AaronH FP 3 months ago

    Hello,
    I’m receiving an exception when I attempt to set the SpreadChart.CategoryFormula property to a formula whose data does not start at row 0. Attached is a sample application. Click the “success” button and the chart generates just fine. Click the “fail” button and it adds some rows above the data used in the chart but then fails on the formula. I am attempting to adjust the formula to account for the data not starting in the first row of the Spread. Ultimately I want to have multiple sets of data and grids on a single sheet going down.

    Thanks,

    Aaron

    Attachments:
    You must be logged in to view attched files.
  • 117p
    Sean Lawyer117p 3 months ago

    Hi Aaron,

    The problem is in the code making the CellRange:

    CellRange rng = new CellRange(rowIndex - Data.Count, 1, rowIndex, 4);

    That should be:

    CellRange rng = new CellRange(rowIndex - Data.Count, 1, Data.Count, 4);

    CellRange constructor arguments specify row, column, rowCount, columnCount, so when you click “fail” it makes the range (5, 1, 45, 4) which has 45 rows (and hence why the category formula with only 40 rows fails).

    Regards,
    -Sean

  • AaronH FP 3 months ago

    Thanks, Sean! I knew it had to be some simple that I was overlooking. Can’t wait to finally implement charts in my application.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to create new topics.