Export To Excel with formatted Text without installing excel on the server

I have the following export function to export data from datatable to excel on the client vai web browser and it works fine but I cannot add any text decoration to the strings. For example, in the code below, the first bolded section name "Header" i am trying to give the lable control with some text and color information but when i write lable with response.write it give me this "System.Web.UI.WebControls.Label" in the cell but the rest works, I need to find a way to put text decoration on the excel programmatically without having to install excel on the server.

Any help will be much appreciated.

Public Shared Sub ExportToExcelFromDataTable(ByVal FileName As String, ByVal XportDT As DataTable, ByVal FilterExp As String)
                HttpContext.Current.Response.Clear()
                HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", FileName))
                HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"

                'Header
                Dim Headerlbl As New Label
                Headerlbl.Text = "Raw Student Data Listing"
                Headerlbl.ForeColor = Drawing.Color.Red               
                HttpContext.Current.Response.Write(Headerlbl)
                HttpContext.Current.Response.Write(ControlChars.NewLine)

                'Step 1: Add Header Row
                For Each DC As DataColumn In XportDT.Columns
                    HttpContext.Current.Response.Write(DC.ColumnName & ControlChars.Tab)
                Next

                HttpContext.Current.Response.Write(ControlChars.NewLine)

                'Step 2: Add Rows of Data
                Dim myDataRows As DataRow() = XportDT.Select(FilterExp)
                For Each DR As DataRow In myDataRows
                    For Col As Integer = 0 To XportDT.Columns.Count - 1
                        HttpContext.Current.Response.Write(DR(Col).ToString & ControlChars.Tab)
                    Next
                    HttpContext.Current.Response.Write(ControlChars.NewLine)
                Next
                HttpContext.Current.Response.End()
            End Sub

 Thanks

Kabir

0
kabir
1/9/2009 7:06:24 PM
asp.net.free-for-all 9281 articles. 0 followers. Follow

4 Replies
545 Views

Similar Articles

[PageSpeed] 53

Three options come to mind:

1) If your audience will all be using Excel 2007, or have the Office 2007 conversion kit, you could use the Open Document Format library to generate DOCX files.

2) Carlos Ag's ExcelXMLWriter (http://www.carlosag.net/Tools/ExcelXmlWriter/)

3)  Depending on your budget, Aspose Celle (http://www.aspose.com/categories/file-format-components/aspose.cells-for-.net-and-java/default.aspx)

I've only used #2 and #3.  CarlosAg's is good for most basic stuff, but Aspose is wonderful and very full featured.


If my post is your answer, please mark it as the answer. It will bring good karma.

Crystal Alliance
My Blog
Florist Blogs
0
rjdudley
1/9/2009 9:30:51 PM

Thanks for the response, could you explain number one any further... as for numbertwo and three i dont want to buy or use any third paty tools, if possible i would like to do that on my own... Any articles or tutorials regarding my question will be really helpful.

 Thanks again.

Kabir -{

0
kabir
1/9/2009 9:38:27 PM

A third party library will make life a little easier, but it's still pretty easy to work with XSLX files, since they're just XML.  You might find what you need at http://blogs.msdn.com/brian_jones/archive/2008/11/04/document-assembly-solution-for-spreadsheetml.aspx.  If you want more details on the OpenXML format, have a look at http://openxmldeveloper.org/.


If my post is your answer, please mark it as the answer. It will bring good karma.

Crystal Alliance
My Blog
Florist Blogs
0
rjdudley
1/9/2009 9:59:40 PM

Thank for all you help i think i will use this xml schema to develop my xls thanks.

Kabir

0
kabir
1/13/2009 6:00:27 PM
Reply:

Similar Artilces:

Aspose.Excel.Express 1.1 Released!
Aspose.Excel.Express 1.1 Released! Version 1.1.0.0 Released on November 30 2004 The .Net Excel.Express spreadsheet reporting component which enables you to delivers real Excel spreadsh...

Aspose.Excel.Express 1.2 Released!
Aspose.Excel.Express 1.2 Released! Version 1.2.0.0 Released on January 24 2005 The .Net Excel.Express spreadsheet reporting component which enables you to delivers real...

Export to excel without third party tools and without Excel on the Application Server.
I need to export a stored procedure in SQL Server to Excel. The stored procedure has two parameters. I need to Export to excel without third party tools and without Excel on the Application Server. Whats the easiest and best way?   p Unfortunately, this is again a link to another forum www.universalthread.com where this topic was discussed and several solutions provided. <B>Re: Create an Excel file (xls)</B> Thread #1304564 Message #1304876 I don't want to copy and paste code, you may want to check this yourself, but you have to become a member of the site in...

export to excel without installing office on the server
Hi this is killing me,  i need to deploy a website with some excel stuff , but i don't have to install the officeon the server, I read about OWC but where i can found some tutorial that can help me, but to use OWC the client must have office?and my real problem is that my boss told me he doesn't want to use no HTML vns_aplicaction ,excel, he want to  to formateverything like is the assembly microsoft.interop.excel , is there any way how i can make reference to those interop, bc when i run my application in my computer runs perfect but when i run into t...

how to deploy excel object on windows 2003 server without installing excel on it
Hi all,I am using excel application object in my asp.net web sit app.if I install excel on my system it works absolutely..fine.But I need to deploy the app on our server where microsoft office (excel) and VS 2005 wont be installed ..I should be able to run it locally and remotely as it is a website..Guys is there any way to add or register kind of thing..help me asap How are you calling the excel object? Something like below?Dim oExcel As Excel.ApplicationoExcel = New Excel.Application For this you need to add a reference to a DLL in your VS project, when you deply, the DLL will ...

Import excel file using sql query without installing excel on the server
Hi, I want to import excel file using sql query. MS Excel is not installed on the server. I am using sql server 2005. I do not want to achieve this by code. I want it using sql query only.  I have used openrowset but it requires MS Excel to be installed on the server. Thanks, Ashish.    Ashish Chaugule ashish_chaugule: Hi, I want to import excel file using sql query. MS Excel is not installed on the server. I am using sql server 2005. I do not want to achieve this by code. I want it using sql query only.  I have used openrowset but it requires M...

Exporting to Excel in Crystal Reports .NET
sir,   I want to export Crystal report to Excel and the following is the code i wrote in the button click.ReportDocument rptExcel = new ReportDocument() ;string strExportFile = "C:/Session_SessionID.xls" ;rptExcel = new RptJobOrderRecap();//report namerptExcel.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile ;rptExcel.ExportOptions.ExportFormatType = ExportFormatType.Excel;ExcelFormatOptions objExcelOptions = new ExcelFormatOptions();objExcelOptions.ExcelUseConstantColumnWidth = false ;rptExcel.ExportOptions.FormatOptions = objExcelOptions ;DiskFileDestinationOp...

Exporting to Excel (No MS EXcel on the Server)
I am binding a dataset to my GridView. I want to Export it to Excel. Server does not have MS Excel and we cannot install it. All the Client Machines will have MS Excel. How to start about it? Any Article to start with? Thanks I think if you install the Microsoft Visual Studio 2005 Tools for the Microsoft Office System you will have access to the Microsoft.Office.Interop.Excel namespace to do this. There is also a runtime that must be installed (or setup with the deployment project) on the server. Here's a good starting pount from MSDN.  Check this article - http://mattberseth.c...

export dataset to a excel(2003) template and send it to client without installing office on the server
Hi I have a formated excel template in excel 2003 (mytemplate.xls) . I need to write values from my dataset in to this excel template and send the excel file to the client via browser. I want to do this without installing ms office in my web server.also i dont want to use any thirdparty controls.  how to do this? this is possible or not? I tried using Interops which creates a server instance which is not recommended. Any timely help would be appreciated.Thanks,Arun.K.Ssarunmphil@yahoo.com   sarunmphil: Hi I have a formated excel template in excel 2003 (mytemplate.xls) . I...

Export To Excel Excel
Do we have any facility to export grid data in Excel with using Report Tool. Just a question, Will Response.contenet Type will work here Thanks, private void btnExportToExcel_Click(object sender,System.EventArgs e) { ExportToExcel("Report.xls",DataGrid1); } private void ExportToExcel(string strFileName,DataGrid dg) { Response.Clear(); Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("content-disposition", "attachment;filename=" + strFileName); Response.Charset = ""; this.EnableVi...

Export GridView to Excel (xlsx, Excel 2007 Format)
Hi again, I was looking online for a way to export gridview to excel in Excel 2007 Format (xlsx). I could only find one solution, gridviewtoexcel. Is this the only way to do it? ThanksBullpitThanks,MaxLet Me Google That For You! Hey Bullpit,Please, do the following : 1st in the html side of your page write this ... <%@ Page Language="VB" EnableEventValidation ="false"  AutoEventWireup="false" CodeFile="marquee.aspx.vb" Inherits="marquee" %>2nd this is the vb code protected void btnSubmit_Click(object sender, ImageClickEventAr...

Exporting GridView in to Excel and Text Format
hi, I want to export the data in GridView Control into an Excel Sheet (.xls) and Text (.txt) please advise...and what will be the case if the Paging is enable and gridview is having multiple pages of data. Regards In button_click event write following code.   GridView1.AllowPaging = false;   ////////write this code only if paging is enabled. GridView1.DataBind();////////write this code only if paging is enabled. Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");///////for text file write FileNam...

Export Datagrid value to excel sheet(Formatted excel sheet)
Hai     Export Datagrid  value to excel sheet(Formatted excel sheet). I want to copy the content of datagrid(dataset ) to excel sheet . Also i want to  change the header style(Change the background color of the header in excel sheet). Pls help me.....................

Visualization file Excel in Browser, without Excel installing on the client pc
I'm developping a web application,  in which i create a xls file, but i would like to display this file in the browser, and i'd like to know, in which way, i could develop this.Googbye Mariano Hi,  Way can be creating dataset from excel sheet and the displaying in form of datagrid.I think other than this way you cannot display excel data.My Blog: DotNetError@BhatiaWorldDont forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped. Hi it...

Web resources about - Export To Excel with formatted Text without installing excel on the server - asp.net.free-for-all

Help:Installing Japanese character sets - Wikipedia, the free encyclopedia
This help page will help you install Japanese character sets so that your computer will display them properly on the internet in your web browser ...

Earn Free Facebook Credits For Installing Apps — Of Course, There’s A Catch
This looks pretty cool at first: Earn free Facebook Credits for installing applications on your iPhone or Android device. AppDog offers this ...

Rooting and installing Android 1.5 JesusFreke - Flickr - Photo Sharing!
More information at: android.noisepages.com/2009/05/rooting-pics/

Installing ClearCal Anti-Glare Film for Glossy Displays - YouTube
Demonstration of how to install a RadTech ClearCal Anti-Glare Film on a MacBook Pro. ClearCal eliminates glare on glossy displays like Apple's ...

Fatal unit fire: Builder Ray Finianos reduced height of building to avoid installing fire sprinklers ...
The builder of&nbsp;a south-west Sydney unit block where a young woman plunged to her death during a ferocious fire told a certifier to reduce ...

'Green' light bulb moment for councils installing LED street lights
Nine Sydney councils are getting ready to turn off the lights &ndash; 13,000 of them &ndash; to save more than $20 million.

Iran installing new nuclear equipment
Sky News is Australia's leader in 24-hour news. Iran has begun installing next-generation equipment at one of its main nuclear plants, a new ...

Peter Garrett believed installing insulation batts 'not that hard', royal commission told
Former environment minister Peter Garrett believed installing insulation batts was ''not that hard'' based on his own personal experience, an ...

Gillard defends installing Slipper
BBC News Gillard defends installing Slipper Sydney Morning Herald Prime Minister Julia Gillard has defended her decision to install Peter ...

CSIRO says installing solar panels on roofs of businesses could take pressure off the electricity grid ...
Installing more solar panels on the roofs of businesses would help Australia's energy grid cope with increased demand.

Resources last updated: 12/16/2015 6:28:05 PM