ASP.NET 2.0 C# with Excel
-
hi, Have any method that can retrieve record from database then export it to Excel file(the function that set the width of each field is needed) Have any idea.... From:Eva wonG
The server can do this. ASP.NET will not be involved in the process tho. It will be code that uses the Excel libraries, and will require excel on the server.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
The server can do this. ASP.NET will not be involved in the process tho. It will be code that uses the Excel libraries, and will require excel on the server.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
hi, Have any method that can retrieve record from database then export it to Excel file(the function that set the width of each field is needed) Have any idea.... From:Eva wonG
Hi, I didnt come across any such method ? But you can acieve it using this code. ----------------------------------------------------------------------- string s = "select * from person"; DataSet ds = GetDataSet(s); GridView1.DataSource = ds; GridView1.DataBind(); Response.ContentType = "application/ms-excel"; Response.AddHeader("Content- Disposition", "inline;filename=ExcelFile.xls"); ------------------------------------------------------------------------ I am not convince with Christian Graus answer. Excel is optional at Server. But it is required at Client Machine. If it is not installed at Client Machine, user cannot display the excel file, but he can download.
-
Hi, I didnt come across any such method ? But you can acieve it using this code. ----------------------------------------------------------------------- string s = "select * from person"; DataSet ds = GetDataSet(s); GridView1.DataSource = ds; GridView1.DataBind(); Response.ContentType = "application/ms-excel"; Response.AddHeader("Content- Disposition", "inline;filename=ExcelFile.xls"); ------------------------------------------------------------------------ I am not convince with Christian Graus answer. Excel is optional at Server. But it is required at Client Machine. If it is not installed at Client Machine, user cannot display the excel file, but he can download.
The original post said " export it to Excel file(the function that set the width of each field is needed)" Christian is quite correct, to do this you need Excel installed on the server. What you are proposing is to display the data as Excel in a web page - not the same thing, but a viable work around as long as the fiel does not need writing to the server for some reason.
Bob Ashfield Consultants Ltd
-
Hi, Christian Graus Can you send me the regarding code to me for refer..... THANKS From: eva
When you download the Microsoft tools for Office, so you can do this, it will come with samples.
Christian Graus Please read this if you don't understand the answer I've given you "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
-
hi, Have any method that can retrieve record from database then export it to Excel file(the function that set the width of each field is needed) Have any idea.... From:Eva wonG
Hi, There is an excellent article here on codeproject, that might help you... http://www.codeproject.com/KB/webforms/DAtaGridExportToExcel.aspx[^]
Those who want most to speak up, are often those who have nothing clever to say.