//i'm using VS 2008, dll as Microsoft.Office.Interop.Excel
//sample code..
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlApp = new Excel.ApplicationClass();
xlWorkBook = xlApp.Workbooks.Add(misValue);//create new work book
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
//CREATING ONE Rectangle shape
xlWorkSheet.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, 47, 24, 500, 90);
Microsoft.Office.Interop.Excel.Shape[] myShapes = new Microsoft.Office.Interop.Excel.Shape[1];
//adding textbox
myShapes[0] = xlWorkSheet.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 75, 60, 70, 30);
myShapes[0].TextFrame.Characters(misValue, misValue).Text = "Tracking";
//ブラウザからダウンロードオプションを使用してください。ここ1)memorystreamに書き出す方法... 2)ブラウザからExcelファイルをダウンロードする方法... Micosoft.Office.Interop.Excelとc#
context.Response.ContentType = "application/vnd.ms-excel";
context.Response.AddHeader("Content-Disposition", "attachment; filename= report.xls");
//私は
string file = context.Server.MapPath("new.txt");
Byte[] myByte = File.ReadAllBytes(file);
context.Response.Clear();
context.Response.BinaryWrite(myByte);
context.Response.Flush();
context.Response.Close();
たちはMemoryStreamを内のオブジェクトを保存するためには、IPersistStreamインターフェイスを使用することができます..私は一時ファイルを使用せずに必要file.but一時的なテキストを使用していますか?
をしないでくださいこの! Office Automationライブラリは、デスクトップアプリケーションの内部で使用するように設計されています。 ASP.NETアプリケーションからそれらを使用しようとすると、さまざまな方法で失敗します。 –
なぜCSVにエクスポートしないのですか? – doogle
@ani:ASP.NETの期間は使用しないでください。 –