使用 closed xml 将 gridview 导出到 excel,相隔 1 列
export gridview to excel using closed xml with 1 column apart
我正在使用 ClosedXML 将 gridview 导出到 excel,我希望我的输出有一个单独的列。像这样。
这是我的 gridview header 部分的代码。
for (col = 0; col < headerCount; col++)
{
worksheet.Cell(3, current + 1).Value = GridView1.HeaderRow.Cells[col].Text;
}
注意:我的 gridview 列数是动态的。
试试这个:
for (col = 0; col < headerCount; col++)
{
worksheet.Cell(3, current * 2 + 1).Value = GridView1.HeaderRow.Cells[col].Text;
}
我正在使用 ClosedXML 将 gridview 导出到 excel,我希望我的输出有一个单独的列。像这样。
这是我的 gridview header 部分的代码。
for (col = 0; col < headerCount; col++)
{
worksheet.Cell(3, current + 1).Value = GridView1.HeaderRow.Cells[col].Text;
}
注意:我的 gridview 列数是动态的。
试试这个:
for (col = 0; col < headerCount; col++)
{
worksheet.Cell(3, current * 2 + 1).Value = GridView1.HeaderRow.Cells[col].Text;
}