110,534
社区成员
发帖
与我相关
我的任务
分享
Microsoft.Office.Interop.Excel.Application excel = null;
Microsoft.Office.Interop.Excel.Workbook xBook = null;
Microsoft.Office.Interop.Excel._Worksheet wks = null;
string dataFilePath = System.Environment.CurrentDirectory + @"\Model.xls";
try
{
excel = new Microsoft.Office.Interop.Excel.Application();
excel.Visible = false;
excel.DisplayAlerts = false;
//excel.ActivePrinter = "Citizen CLP-521Z";
xBook = excel.Application.Workbooks._Open(dataFilePath, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing, Missing);
if (xBook == null)
{
xBook = excel.Application.Workbooks.Add(true);
}
wks = (Microsoft.Office.Interop.Excel._Worksheet)xBook.ActiveSheet; //取得当前worksheet
wks.Cells[2, 2] = "'" + sScheduleDate;//.Remove(10);
wks.Cells[3, 2] = "'" + sPatientID;
wks.Cells[4, 2] = "'" + sName;
wks.Cells[5, 2] = "'" + sSex;
wks.Cells[5, 4] = "'" + nAge;
wks.Cells[6, 2] = "'" + sCheckType;
object omo = new object();
//打印预览
//wks.PrintPreview(omo);
//不预览打印
wks.PrintOut(1, 1, 1, false, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
//wks.PrintOut(omo, omo, omo, omo, omo, omo, omo, omo);
//xBook.Saved = true;
xBook.Save();
excel.Application.Workbooks.Close();
excel.Application.Quit();
excel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);