Что добавить в код, чтобы выводились такие же заголовки? Иначе в Word выходит это:
private void button7_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
Document doc = app.Documents.Add(Visible: true);
Range r = doc.Range();
Table t = doc.Tables.Add(r, 1, 6);
t.Borders.Enable = 1;
using (SqlConnection conn = new SqlConnection(@"Data Source=DESKTOP-LRHFEMI\SQLEXPRESS;Initial Catalog=Delomedika;Integrated Security=True"))
{
try
{
conn.Open();
using (SqlCommand cmd = new SqlCommand("SELECT * FROM Zayavki", conn))
{
using (SqlDataReader reader = cmd.ExecuteReader())
{
int j = 1;
while (reader.Read())
{
t.Rows.Add();
for (int i = 1; i <= reader.FieldCount; i++)
{
t.Cell(j, i).Range.Text = reader.GetValue(i - 1).ToString();
}
j = j + 1;
}
}
}
t.Rows.Last.Delete();
doc.Save();
try
{
doc.Close();
app.Quit();
}
catch (Exception help)
{
MessageBox.Show(help.Message);
}
}
catch (Exception help)
{
MessageBox.Show(help.Message);
}
}
}
DataFridView