发布网友 发布时间:2024-10-03 17:23
共1个回答
热心网友 时间:2024-10-09 17:26
object[,] objdate = new object[rownum, 9];m_objRange = m_objSheet.get_Range("A5", Missing.Value);m_objRange = m_objRange.get_Resize(rownum, 9);//水平对齐--右对齐m_objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignRight;//文本格式m_objRange.NumberFormat = "@";m_objRange.Value2 = objdate;//保存并施放EXECL资源m_objBook.Saved = true;m_objExcel.DisplayAlerts = false;m_objSheet._Saves (FileWrite,Missing.Value,Missing.Value,Missing.Value,Missing.Value, Missing.Value,Missing.Value,Missing.Value,Missing.Value); m_objBook.Close(false, Missing.Value, Missing.Value);if (m_objExcel != null){m_objExcel.Workbooks.Close();m_objExcel.Quit();System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objExcel);System.GC.Collect();}if (m_objSheet != null){System.Runtime.InteropServices.Marshal.ReleaseComObject(m_objSheet);这样写可以 VS2008测试通过