0
我在使用FastReport將我的DataGridView中的值導出爲PDF時遇到問題。在Visual C#2010 Express中使用FastReport從DataGridView導出爲PDF
我相信我有正確的代碼,但我的PDF中的行似乎沒有更新,它只顯示我的DataGridView的第一行。
private void CreateDataSet()
{
ds = new DataSet();
DataTable table = new DataTable();
table.TableName = "ABCD";
ds.Tables.Add(table);
{
for (int i = 0; i < dg.ColumnCount; i++)
{
table.Columns.Add(dg.Columns[i].HeaderText);
}
for (int j = 0; j < dg.Rows.Count; j++)
{
table.Rows.Add(dg.Rows[j].Cells[0].FormattedValue.ToString(), dg.Rows[j].Cells[1].FormattedValue.ToString(), dg.Rows[j].Cells[2].FormattedValue.ToString(), dg.Rows[j].Cells[0].FormattedValue.ToString(), dg.Rows[j].Cells[4].FormattedValue.ToString(), dg.Rows[j].Cells[5].FormattedValue.ToString());
}
}
}
我甚至試圖消除For
循環以及與此替換它:
table.Rows.Add(dg.Rows[0].Cells[0].FormattedValue.ToString(), dg.Rows[0].Cells[1].FormattedValue.ToString(), dg.Rows[0].Cells[2].FormattedValue.ToString(), dg.Rows[0].Cells[0].FormattedValue.ToString(), dg.Rows[0].Cells[4].FormattedValue.ToString(), dg.Rows[0].Cells[5].FormattedValue.ToString());
table.Rows.Add(dg.Rows[1].Cells[0].FormattedValue.ToString(), dg.Rows[1].Cells[1].FormattedValue.ToString(), dg.Rows[1].Cells[2].FormattedValue.ToString(), dg.Rows[1].Cells[0].FormattedValue.ToString(), dg.Rows[1].Cells[4].FormattedValue.ToString(), dg.Rows[1].Cells[5].FormattedValue.ToString());
但無濟於事。
下面是在PDF上面的代碼的輸出:http://i1296.photobucket.com/albums/ag2/paozaf/output_zpsde2b6278.png
期望的數據輸出:http://i1296.photobucket.com/albums/ag2/paozaf/desiredoutput_zps44a27fac.png
你的問題不是很清楚..where是PDF導出問題?您在導出或填充數據集時遇到問題嗎? –
好的,對不起。我添加了輸出的打印屏幕和所需的輸出。 – PaZa