Excel.Workbooks oBooks;
Excel.Workbook book;
Excel.Sheets oSheets;
Excel.Worksheet sheet;
Excel.Range Cells;
Excel.Application pltExcel;
pltExcel = new Excel.Application();
SaveFileDialog xlsSave = new SaveFileDialog();
xlsSave.Filter = "xls Files|*.xls";
xlsSave.FileName = this.txtLotID.Text;
DialogResult dlgResult;
dlgResult = xlsSave.ShowDialog();
if (dlgResult == DialogResult.OK)
{
pltExcel.Workbooks.Add(true);
oBooks = pltExcel.Workbooks;
book = oBooks[1];
oSheets = book.Worksheets;
sheet = (Excel.Worksheet)oSheets[1];
sheet.Name = this.txtLotID.Text;
Cells = sheet.Cells;
//
sheet.get_Range("A1", "I50").Borders.LineStyle = 1;
sheet.get_Range("A1", "I50").Borders.Weight = 3;
sheet.get_Range("A1", "I50").Cells.Interior.Color = System.Drawing.Color.LightGray.ToArgb();
//sheet.get_Range("A1", "I50").Font.Size = 8;
//sheet.get_Range("A1", "I50").Font.Bold = true;
//sheet.get_Range("A1", "I50").Font.Name = "思源黑体 CN Regular";
//Cells[17, 1] = "NO";
//Cells[17, 2] = "Description";
//sheet.get_Range("B17", "C17").Merge(Cells.get_Range("B17", "C17").MergeCells);
//Cells[17, 4] = "Tool";
//Cells[17, 5] = "Recipe";
//Cells[17, 6] = "SMIF ID";
//Cells[17, 7] = "Sign In";
//Cells[17, 8] = "Sign Out";
//Cells[17, 9] = "Memo";
//sheet.get_Range("A17", "I17").Font.Size = 12;
//Cells[11, 1] = "Frame CD SPEC";
//Cells[11, 5] = "Registration SPEC";
//Cells[11, 6] = "Defect SPEC";
//sheet.get_Range("A11", "C11").Merge(Cells.get_Range("A11", "C11").MergeCells);
//sheet.get_Range("D11", "E11").Merge(Cells.get_Range("D11", "E11").MergeCells);
//sheet.get_Range("F11", "I11").Merge(Cells.get_Range("F11", "I11").MergeCells);
// sheet.get_Range("A11", "I11").Font.Size = 12;
// Cells[16, 1] = "ENG NOTE";
pltExcel.ActiveWorkbook.SaveAs(xlsSave.FileName,
Excel.XlFileFormat.xlWorkbookNormal, Type.Missing,
Type.Missing, Type.Missing, Type.Missing,
Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, Type.Missing);
pltExcel.Quit();
Marshal.ReleaseComObject(Cells);
Marshal.ReleaseComObject(sheet);
Marshal.ReleaseComObject(oSheets);
Marshal.ReleaseComObject(book);
Marshal.ReleaseComObject(oBooks);
Marshal.ReleaseComObject(pltExcel);
pltExcel = null;
oBooks = null;
book = null;