public int InsertEntry(ref ExcelDataUnit unitData) { CouplingRetData retData = unitData.couplingRetData; double totalTime = unitData.timeCost; if (index < 0) { return(index); } xls_exp = new Microsoft.Office.Interop.Excel.ApplicationClass(); xls_book = xls_exp.Workbooks.Open(fName, Missing.Value, false, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, true, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); xls_sheet = (Microsoft.Office.Interop.Excel._Worksheet)xls_book.Worksheets.get_Item(1); xls_sheet.Cells[index, 1] = Convert.ToString(index - startIndex + 1); xls_sheet.Cells[index, 2] = unitData.prdId; xls_sheet.Cells[index, 3] = retData.vpp.ToString(); xls_sheet.Cells[index, 4] = unitData.Vbr.ToString("F2"); xls_sheet.Cells[index, 5] = retData.lx1.ToString(); xls_sheet.Cells[index, 6] = retData.ly1.ToString(); xls_sheet.Cells[index, 7] = retData.lz.ToString(); xls_sheet.Cells[index, 8] = retData.lx2.ToString(); xls_sheet.Cells[index, 9] = retData.ly2.ToString(); xls_sheet.Cells[index, 10] = Convert.ToString(((double)retData.duration) / 1000000); xls_sheet.Cells[index, 11] = totalTime.ToString(); xls_sheet.Cells[index, 12] = DateTime.Now.ToString("yyyy-MM-dd HH:mm"); xls_sheet.Cells[index, 13] = unitData.couplingRetData.vpp1.ToString(); xls_sheet.Cells[index, 14] = unitData.VAPD_Vbr3V_Iop_Vpp.ToString(); object misValue = System.Reflection.Missing.Value; // if (index == 3) // { xls_sheet.Columns.AutoFit(); // } xls_book.Saved = true; //xls_exp.ActiveWorkbook.SaveCopyAs(fName); xls_book.Save(); //xls_book.SaveAs(fName, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue); Close(); return(index++); }
public int InsertEntry(ref ExcelDataUnit dataUnit) { return(awExcle.InsertEntry(ref dataUnit)); }