I need your help, I'm trying to export the content od a DataGridView to MS Word Table using Office Interop
.
I have a problem, the data in a Word table is mislaced, can someone help me?.
I attached 2 images with input and output and part of my code.
Table thirdTable = document.Tables.Add(para3.Range, dataGridViewObjednavka.RowCount, dataGridViewObjednavka.ColumnCount, ref missing, ref missing);
{
for (int i=0; i<dataGridViewObjednavka.Rows.Count;i++)
{
for (int j=0; j<dataGridViewObjednavka.Columns.Count; j++)
{
thirdTable.Cell(i, j).Range.Text = Convert.ToString(dataGridViewObjednavka.Rows[i].Cells[j].Value);
}
}
}
I just solved problem by myself....Only have to add +1 in thirdTable.Cell(i+1, j+1).......Thank you :)