Sign UpSign Up   Sign InSign In Welcome Guest,
Live Chat Live Chat

Column Headers missing while using GridWeb1.WebWorksheets.SaveToExcelFile

Last post 07-02-2009, 8:32 AM by Amjad Sahi. 1 replies.
Sort Posts: Previous Next
  •  07-02-2009, 7:41 AM 186591

    Column Headers missing while using GridWeb1.WebWorksheets.SaveToExcelFile .NET

    Hi,

    I am using Aspose.grid as evaluation version & on the last phase of process.

    Can u please let me know the pricing for the product..will manage to buy in last week of this month.

    I am facing problem with the following code:

    Private Sub btnSaveGrid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveGrid.Click

    Dim strFileName As String

    strFileName = Server.MapPath(".") & "\Required Files\Sold\SoldDetails" & FormatDateTime(Date.Now(), DateFormat.LongDate) & ".xls"

    Try

     

    GridWeb1.WebWorksheets.SaveToExcelFile(strFileName, FileFormatType.Excel2003)

    Dim file As System.IO.FileInfo = New System.IO.FileInfo(strFileName)

    If file.Exists Then

    Response.Clear()

    Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name)

    Response.AddHeader("Content-Length", file.Length.ToString())

    Response.ContentType = "application/vnd.ms-excel"

    Response.WriteFile(file.FullName)

    Response.End()

    Else

    Response.Write("<script lang=""javascript"">alert('File does not exist on server');</script> ")

    End If

    Catch ex As Exception

    Finally

    strFileName = ""

    End Try

    End Sub

    Its a .net Button from which i am facilating user to download grid as excel.I am facing problem when user will save the grid as excel, he should be able to see column names....where as its saving only data not the columns.

     

    Ashutosh

     

    for ex...i am showing plot no & phone no..& when i will save the Data as excel..it should save like...

    PlotNo               PhoneNo.

    1                           568142

    2                           2354876

     

    where as its showing

    1                           568142

    2                           2354876

     

    So how can i get headers while saving sheet using   SaveToExcelFile Method

     

     
  •  07-02-2009, 8:32 AM 186597 in reply to 186591

    Re: Column Headers missing while using GridWeb1.WebWorksheets.SaveToExcelFile

    Hi,

    Well, if you set the column headers using cells.SetColumnCaption() method, the headers won't be rendered in the exported excel file, this is due to the fact that MS Excel does not allow this by default. I think you should create column headers in the sheet (in-line headers) cells and then save the excel file, i.e..,

                   A                        B  

    1          PlotNo               PhoneNo.

    2          1                           568142

    3          2                           2354876

     

    And for sales inquires, please post a query @ Aspose.Purchase forum: http://www.aspose.com/community/forums/aspose.purchase/220/showforum.aspx  and one of our sales representative will help you soon.

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Sialkot Team
    Contact Us
     
View as RSS news feed in XML