Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7686117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:24:24+00:00 2026-05-31T19:24:24+00:00

I am pulling two fields and putting them together with a -. When I

  • 0

I am pulling two fields and putting them together with a “-“. When I export to excel it seems to think that the string is a date and converts it from 11-11 to 11-Nov. I can’t seem to figure out how to fix this.

I am exporting a gridview into excel. This asp.net using .net 3.5 and vb.net within VS 2008.

    Response.Clear()

    Response.Buffer = True

    'grab filename from filename box
    'if does not exist then do default naming
    Dim filename As String
    If filenameTextBox2.Text <> "" Then
        filename = "attachment;filename=" + filenameTextBox2.Text + ".xls"
    Else
        filename = "attachment;filename=GridViewExport.xls"
    End If

    Response.AddHeader("content-disposition", filename)

    Response.Charset = ""

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



    Dim sw As New IO.StringWriter()

    Dim hw As New HtmlTextWriter(sw)



    GridView1.AllowPaging = False

    GridView1.DataBind()


    'Change the Header Row back to white color

    GridView1.HeaderRow.Style.Add("background-color", "#FFFFFF")



    'Apply style to Individual Cells

    'GridView1.HeaderRow.Cells(0).Style.Add("background-color", "green")

    'GridView1.HeaderRow.Cells(1).Style.Add("background-color", "green")

    'GridView1.HeaderRow.Cells(2).Style.Add("background-color", "green")

    'GridView1.HeaderRow.Cells(3).Style.Add("background-color", "green")



    For i As Integer = 0 To GridView1.Rows.Count - 1

        Dim row As GridViewRow = GridView1.Rows(i)



        'Change Color back to white

        row.BackColor = System.Drawing.Color.White



        'Apply text style to each Row

        row.Attributes.Add("class", "textmode")



        'Apply style to Individual Cells of Alternating Row

        If i Mod 2 <> 0 Then

            'row.Cells(0).Style.Add("background-color", "#C2D69B")

            'row.Cells(1).Style.Add("background-color", "#C2D69B")

            'row.Cells(2).Style.Add("background-color", "#C2D69B")

            'row.Cells(3).Style.Add("background-color", "#C2D69B")

        End If

    Next

    GridView1.RenderControl(hw)



    'style to format numbers to string

    Dim style As String = "<style>.textmode{mso-number-format:\@;}</style>"

    Response.Write(style)

    Response.Output.Write(sw.ToString())

    Response.Flush()

    Response.End()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:24:25+00:00Added an answer on May 31, 2026 at 7:24 pm

    Try adding a Single Quote (‘) before your content.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an INSERT query that is pulling data from two tables and inserting
I have a cakePHP application that is pulling data from two different databases, which
I'm pulling back a Date and a Time from a database. They are stored
How can one programmatically sort a union query when pulling data from two tables?
I have two jobs pulling from a mysql table. They both want to get
I'm pulling in JSON from an external URL. I then want to use that
I'm really pulling my hair out on this one, it seems that I'm having
When pulling dates from a view using JPA and EclipseLink I'm getting dates two
I am pulling two values from a MYSQL database. I have one int and
I have two rows from a table that has many columns. How do I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.