Hi all,
I'm using ExportStructure to export the grid to Excel.
I create a Table named tb and use tb.Cells to write contents.
However, tb.Rows.Count is always zero, even when data is there. Export happens as expected though.
Any idea?
I have to know how many rows a given Table (of ExportStructure) has.
Thank you!
I'm using ExportStructure to export the grid to Excel.
I create a Table named tb and use tb.Cells to write contents.
However, tb.Rows.Count is always zero, even when data is there. Export happens as expected though.
Any idea?
I have to know how many rows a given Table (of ExportStructure) has.
Thank you!
6 Answers, 1 is accepted
0
Hi Igor,
The reason Rows count to be zero is because you fill the cell with data without creating a row objects. In case you need to access the number of rows you have to create a new row object. Note that a new row object is created automatically when you access it by an index. Please check out the following code snippet.
Nevertheless since you are creating the table manually you already know the number of rows so you can create a property which holds this information and use it whenever you need it.
Regards,
Kostadin
Telerik
The reason Rows count to be zero is because you fill the cell with data without creating a row objects. In case you need to access the number of rows you have to create a new row object. Note that a new row object is created automatically when you access it by an index. Please check out the following code snippet.
protected
void
Button1_Click(
object
sender, EventArgs e)
{
ei.ExportStructure structure =
new
ei.ExportStructure();
ei.Table table =
new
ei.Table();
ei.Row row;
for
(
int
i = 0; i < 10; i++)
{
row = table.Rows[i];
for
(
int
j = 0; j < 10; j++)
{
row.Cells[i, j].Value =
"Col"
+ i +
"Row"
+ j;
}
}
structure.Tables.Add(table);
}
Nevertheless since you are creating the table manually you already know the number of rows so you can create a property which holds this information and use it whenever you need it.
Regards,
Kostadin
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Igor
Top achievements
Rank 1
answered on 21 Nov 2014, 05:28 PM
You are using
but should be
right? i is Row and j is Column.
row.Cells[i,j]
[j,i]
0
Igor
Top achievements
Rank 1
answered on 21 Nov 2014, 05:39 PM
Also,
The code is not working. The Cell Value is always empty, even after I assign a value.
I'm using VB.NET:
rowExport = tb.Rows(1)
rowExport.Cells(1, 1).Value = "Test"
Value is still Nothing after execution.
The code is not working. The Cell Value is always empty, even after I assign a value.
I'm using VB.NET:
rowExport = tb.Rows(1)
rowExport.Cells(1, 1).Value = "Test"
Value is still Nothing after execution.
0
Hi Igor,
Please excuse me for misleading you in my previous reply. You need to get the Cell object from the Table and not from the Row object. Please try the following code and let me know about the result.
Regards,
Kostadin
Telerik
Please excuse me for misleading you in my previous reply. You need to get the Cell object from the Table and not from the Row object. Please try the following code and let me know about the result.
protected
void
Button1_Click(
object
sender, EventArgs e)
{
ei.ExportStructure structure =
new
ei.ExportStructure();
ei.Table table =
new
ei.Table();
for
(
int
i = 0; i < 10; i++)
{
for
(
int
j = 0; j < 10; j++)
{
table.Cells[j, i].Value =
"Col"
+ i +
"Row"
+ j;
}
}
structure.Tables.Add(table);
}
Regards,
Kostadin
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Igor
Top achievements
Rank 1
answered on 26 Nov 2014, 03:21 PM
Thank you, using the Table's Cell object worked.
Just some points:
1- in your latest example, you forgot to "create" the row via
right before the columns (j) loop.
2- I believe your i and j has the wrong meaning. j should be cols and i should be rows, taking into consideration the signature of Cells object.
I couldn't find any documentation about this issue (Rows creation) in your website. The documentation for ExportStructure needs to be improved.
Thank you.
Just some points:
1- in your latest example, you forgot to "create" the row via
row = table.Rows[i];
right before the columns (j) loop.
2- I believe your i and j has the wrong meaning. j should be cols and i should be rows, taking into consideration the signature of Cells object.
I couldn't find any documentation about this issue (Rows creation) in your website. The documentation for ExportStructure needs to be improved.
Thank you.
0
Hello Igor,
Note that in most cases you will not need to access the number of row by checking the Rows collection object. Basically when you create the structure programmatically you already know the numbers of rows and in my case they are 10.
Regards,
Kostadin
Telerik
Note that in most cases you will not need to access the number of row by checking the Rows collection object. Basically when you create the structure programmatically you already know the numbers of rows and in my case they are 10.
Regards,
Kostadin
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.