Invalid row index: 11 (must be between 0 and 10)

Posted by: srms on 8 September 2017, 2:38 pm EST

  • Posted 8 September 2017, 2:38 pm EST

    Hi,

    I am populating an excel sheet with dataset rows using far point grid. I upload the template of the excel sheet in to the grid (because i have some static column headers) and assign each row of the fpspread grid to the row of the dataset.  my issue here is, its populating only 10 rows. later i figured out that my template has 10 rows with borders. after 10th row which does not have a border it shows as invalid row. i dont know how much data i might get into my dataset, i can't rely on setting borders. how can i fix this issue. i am guessing i might have to create rows explicitly before inserting data in to them. if so how can i create rows and columns dynamically? I have to create as many rows and columns I have in my dataset... this is my code

      for (int i = 0; i < dt.Rows.Count; i++)
     {
                                   
        for (int j = 0; j < dt.Columns.Count; j++)
         {
                                       
            FpSpread1.ActiveSheetView.Cells[i + 5, j].Text = dt.RowsIdea[j].ToString();
                                       
         }
     }

    FpSpread1.SaveChanges();

    btw I have the newest version of Farpoint...

  • Replied 8 September 2017, 2:38 pm EST

    I'm not sure if I'm understanding your question correctly but if you know what cell type and format you want for each field of each row you are adding to a sheet, you can make a celltype with any style or formating of the type you need and assign that celltype to the Sheets Column and each row you add to that sheet will have that celltype with its style and formatting in the column to which you assigned it. I tested this with this code.


    FarPoint.Win.Spread.CellType.DateTimeCellType dct = new FarPoint.Win.Spread.CellType.DateTimeCellType();


    FarPoint.Win.Spread.CellType.NumberCellType nct = new FarPoint.Win.Spread.CellType.NumberCellType();


    nct.FixedPoint = true;


    nct.DecimalPlaces = 2;


    FarPoint.Win.Spread.CellType.CurrencyCellType cct = new FarPoint.Win.Spread.CellType.CurrencyCellType();


               


    fpSpread1.Sheets[0].RowCount = 1;


    fpSpread1.Sheets[0].ColumnCount  = 3;


    fpSpread1.Sheets[0].Columns[0].CellType = dct;


    fpSpread1.Sheets[0].Columns[1].CellType = nct;


    fpSpread1.Sheets[0].Columns[2].CellType = cct;


     


    private void button1_Click(object sender, EventArgs e)


    {


         fpSpread1.ActiveSheet.AddRows(fpSpread1.ActiveSheet.Rows.Count, 1);


    }


     

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels