Export excel error fomula
Microsoft.Office.Interop.Excel.Application oExcel = null;
//Microsoft.Office.Interop.Excel.Workbook oBook = null;
Microsoft.Office.Interop.Excel._Workbook oBook = null;
Microsoft.Office.Interop.Excel.Worksheet oSheet = null;
Microsoft.Office.Interop.Excel.Range oRng;
object missing = Type.Missing;
try
{
oExcel = new Microsoft.Office.Interop.Excel.Application();
oBook = oExcel.Workbooks.Open("E:\\demo\\11-3-07\\FasterServices\\WebSite\\bill\\bill.xls", missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);
//oExcel.Visible = true;
oBook.Activate();
oSheet = (Microsoft.Office.Interop.Excel.Worksheet)oBook.Wo rksheets["gen"];
oSheet.get_Range("D33", "D33").Formula = "=BAHTTEXT(I31)";
//oSheet.get_Range("D33", "D33").set_Value(Type.Missing, "=BAHTTEXT(I31)");
oSheet.SaveAs("C:\\Documents and Settings\\Administrator\\Desktop\\NMDS1.xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlExce l7, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
oExcel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComO bject(oExcel);
System.Runtime.InteropServices.Marshal.ReleaseComO bject(oBook);
System.GC.Collect();
}
catch (Exception ex)
{
//Response.Write("Error accessing Excel: " + ex.ToString());
}
I use that code obove for export data to excel but I have got this error below about formula please help or suggest.
"A formula in a cell could not be converted because it contains a function that is not available in the file formate to which you are saving. "
|