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


    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.Rows<img src="/emoticons/emotion-55.gif" alt="Idea" />[j].ToString();


    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.

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;">FarPoint.Win.Spread.CellType.<SPAN style="COLOR:#2b91af;">DateTimeCellType</SPAN> dct = <SPAN style="COLOR:blue;">new</SPAN> FarPoint.Win.Spread.CellType.<SPAN style="COLOR:#2b91af;">DateTimeCellType</SPAN>();<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;">FarPoint.Win.Spread.CellType.<SPAN style="COLOR:#2b91af;">NumberCellType</SPAN> nct = <SPAN style="COLOR:blue;">new</SPAN> FarPoint.Win.Spread.CellType.<SPAN style="COLOR:#2b91af;">NumberCellType</SPAN>();<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;">nct.FixedPoint = <SPAN style="COLOR:blue;">true</SPAN>;<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;">nct.DecimalPlaces = 2;<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;">FarPoint.Win.Spread.CellType.<SPAN style="COLOR:#2b91af;">CurrencyCellType</SPAN> cct = <SPAN style="COLOR:blue;">new</SPAN> FarPoint.Win.Spread.CellType.<SPAN style="COLOR:#2b91af;">CurrencyCellType</SPAN>();<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;"><SPAN style="mso-spacerun:yes;">            </SPAN><o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;">fpSpread1.Sheets[0].RowCount = 1;<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;">fpSpread1.Sheets[0].ColumnCount<SPAN style="mso-spacerun:yes;">  </SPAN>= 3;<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;">fpSpread1.Sheets[0].Columns[0].CellType = dct;<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;">fpSpread1.Sheets[0].Columns[1].CellType = nct;<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;">fpSpread1.Sheets[0].Columns[2].CellType = cct;<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;"><o:p> </o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;COLOR:blue;FONT-SIZE:9.5pt;">private</SPAN><SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;"> <SPAN style="COLOR:blue;">void</SPAN> button1_Click(<SPAN style="COLOR:blue;">object</SPAN> sender, <SPAN style="COLOR:#2b91af;">EventArgs</SPAN> e)<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;">{<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;"><SPAN style="mso-spacerun:yes;">     </SPAN>fpSpread1.ActiveSheet.AddRows(fpSpread1.ActiveSheet.Rows.Count, 1);<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:Consolas;FONT-SIZE:9.5pt;">}<o:p></o:p></SPAN>


Need extra support?

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

Learn More

Forum Channels