Excel.Application app=new Excel.Application();
Excel.Workbook wrk=app.Workbooks.Open("//1.xls");
wrk.SaveAs(Request.PhysicalApplicationPath+"//aaaa.htm",Excel.XlFileFormat.xlHtml);
Response.Redirect("aaaa.htm");
这样哪错啊
Excel.Workbook wrk=app.Workbooks.Open("//1.xls");
wrk.SaveAs(Request.PhysicalApplicationPath+"//aaaa.htm",Excel.XlFileFormat.xlHtml);
Response.Redirect("aaaa.htm");
这样哪错啊
public string SaveSheet(string fileName,string SheetName,string FilePath)
{
try
{
oXL = new Excel.Application();
oXL.Workbooks.Open (fileName,Missing.Value ,Missing.Value ,Missing.Value ,Missing.Value ,Missing.Value ,Missing.Value ,Missing.Value ,Missing.Value ,Missing.Value ,Missing.Value ,Missing.Value ,Missing.Value );
//新建一个名称
string nowStr=""+DateTime.Now.Year.ToString()+""+DateTime.Now.Month.ToString()+""+DateTime.Now.Day.ToString()+"";
string newName = nowStr+DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
newName=newName + DateTime.Now.Millisecond.ToString();
oXL.ActiveWorkbook.PublishObjects.Add(Excel.XlSourceType.xlSourceSheet , FilePath+"\\" + newName + ".htm",SheetName,"", Excel.XlHtmlType.xlHtmlStatic,"conn1_20957", Missing.Value).Publish(Missing.Value ) ;
return newName + ".htm";
}
catch( Exception theException )
{
String errorMessage;
errorMessage = "Error: ";
errorMessage = String.Concat( errorMessage, theException.Message );
errorMessage = String.Concat( errorMessage, " Line: " );
errorMessage = String.Concat( errorMessage, theException.Source );
//KillExcelProcess();
return ""; }
}