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/desiredoutput_zps44a27fac.png