using System;
using System.Data;
using System.Data.Common;
using System.Data.OleDb;
using System.IO;
using System.Windows.Forms;
using Graph = Microsoft.Office.Interop.Graph;
using Word = Microsoft.Office.Interop.Word;
namespace WeeklyReporter
{
public partial class MainForm : Form
{
private void CreateReport(DateTime fromDate, DateTime toDate, string reportDepartment)
{
DateTable dt = Query("...");
if (oDoc.Bookmarks.Exists(Convert.ToString(oBookMark)))
{
object nothing = System.Reflection.Missing.Value;
//文档中创建表格
Microsoft.Office.Interop.Word.Table gmsTable = oDoc.Tables.Add(oDoc.Bookmarks[oBookMark].Range, dt.Rows.Count + 1, dt.Columns.Count, ref nothing, ref nothing);
//设置表格样式
gmsTable.Borders.OutsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
gmsTable.Borders.OutsideColor = Word.WdColor.wdColorPaleBlue;
gmsTable.Borders.OutsideLineWidth = Word.WdLineWidth.wdLineWidth225pt;
gmsTable.Borders.InsideLineStyle = Word.WdLineStyle.wdLineStyleSingle;
gmsTable.Borders.InsideColor = Word.WdColor.wdColorPaleBlue;
gmsTable.Borders.InsideLineWidth = Word.WdLineWidth.wdLineWidth225pt;
//填充表格内容
for (int i = 0; i < dt.Columns.Count; i++)
{
gmsTable.Cell(1, i + 1).Shading.ForegroundPatternColor = Word.WdColor.wdColorLightGreen;
gmsTable.Cell(1, i + 1).Range.Bold = 20;
}
gmsTable.Cell(1, 1).Range.Text = "A";
gmsTable.Cell(1, 2).Range.Text = "B";
gmsTable.Cell(1, 3).Range.Text = "C";
gm