title: Stop excel from converting number values to date when exporting
body: <p>I have an application that when I click Run Report button, it will generate data and will be exported to excel.</p>
  
  <p>My problem is that, I have a data in a column which is Requisition No. and the value of this column is for example is like this <code>08-20</code> but when I export it on excel it will became a date <code>20-Aug</code></p>
  
  <p><a href="https://i.stack.imgur.com/tyGqe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tyGqe.png" alt="Excel"></a></p>
  
  <p>Please understand that I already searched for a solution. I saw one similar to my problem but I don't have a gridview, when I click the Run Report it will automatically generate data and then export.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here's my code for <code>fnGeneratereport</code> in <code>DAL</code></p>
  
  <pre><code>  Public Shared Function FnGenerateReport(ByVal rm As ReportModel) As DataTable
          Dim dtbReport As New DataTable
          Dim strQuery As New StringBuilder
  
          strQuery.Append("SELECT R.iResumeID, R.vFirst, R.vMiddle, R.vLast, J.vGeneric, JC.vJobClass, R.dtApply, R.iChannelID, ")
          strQuery.Append("HS.vHireStatus, R.dtHire, R.vGender, R.vRace, R.vEthnicity, R.vDisability, R.vVeteran, R.vRemarks AS Remarks, J.ftAdCost,R.iTimeToHire AS iTimeToHire, ")
          strQuery.Append("D.vDivision AS iDivisionID, J.vLocation AS vLocation, J.vLocalised as vLocalised, R.blnEmployee AS blnEmployee, ")
          strQuery.Append("S.vFullName as vFullName, R.vComments as Comments, JT.vJobCodeTitle as JobCodeTitle, ")
          strQuery.Append("J.iPosition as PositionType, J.iJobStatus as JobStatus, J.dtPost as DateJobPosted, R.dtAccepted as JobOfferAcceptedDate, ")
          strQuery.Append("HC.vHCClassificationTitle as ClassificationTitle, J.iHourlySalariedID as HourlySalaried J.vRequisition as vRequisition")
          strQuery.Append("FROM VS_ResumeDB R ")
          strQuery.Append("INNER JOIN VS_JobDB J ON R.iJobID = J.iJobID ")
          strQuery.Append("INNER JOIN VS_CountryDB C ON J.iCountryID = C.iCountryID ")
          strQuery.Append("INNER JOIN VS_DivisionDB D ON (J.iDivisionID = D.iDivisionID) ")
          strQuery.Append("LEFT JOIN VS_StaffDB S ON J.iRecruiterID = S.iStaffID ")
          strQuery.Append("INNER JOIN VS_HireStatusDB HS ON R.iHireStatusID = HS.iHireStatusID ")
          strQuery.Append("LEFT JOIN VS_JobClassDB JC ON J.iJobClassID = JC.iJobClassID ")
          strQuery.Append("LEFT JOIN VS_JobCodeTitleDB JT ON JT.iJobCodeID = J.iJobCodeID ")
          strQuery.Append("LEFT JOIN VS_HCClassificationDB HC on HC.iHCClassificationID = J.iHCClassificationID ")
          strQuery.Append("WHERE R.blnComplete=1 ")
  
          If Len(rm.intCountry) &gt; 0 And rm.intCountry &lt;&gt; 0 Then
              strQuery.Append("AND J.iCountryID=@CountryID ")
          End If
          If Len(rm.intDivisionID) &gt; 0 And rm.intDivisionID &lt;&gt; 0 Then
              strQuery.Append("AND J.iDivisionID=@DivisionID ")
          End If
          If Len(rm.strLocation) &gt; 0 Then
              strQuery.Append("AND J.vLocation LIKE @Location ")
          End If
          If Len(rm.dtePostFrom) &gt; 0 Then
              strQuery.Append("AND R.dtApply&gt;=@PostFrom ")
          End If
          If Len(rm.dtePostTo) &gt; 0 Then
              strQuery.Append("AND R.dtApply&lt;=@PostTo ")
              strQuery.Append("AND J.dtPost&lt;=@PostTo ")
          End If
          If Len(rm.strRequisition) &gt; 0 Then
              strQuery.Append("AND J.vRequisition LIKE @Requisition ")
          End If
          If Len(rm.intHireStatus) &gt; 0 And rm.intHireStatus &lt;&gt; 0 Then
              strQuery.Append("AND R.iHireStatusID=@HireStatus ")
          End If
          If rm.intType = 0 Or rm.intType = 1 Then
              strQuery.Append("AND R.blnEmployee=@Type ")
          End If
          If rm.intJobStatus &lt;&gt; 0 Then
              strQuery.Append("AND J.iJobStatus=@JobStatus ")
          End If
          If Len(rm.dteJobPostFrom) &gt; 0 Then
              strQuery.Append("AND J.dtPost&gt;=@JobPostFrom ")
          End If
          If Len(rm.dteJobPostTo) &gt; 0 Then
              strQuery.Append("AND J.dtPost&lt;=@JobPostTo ")
          End If
  
          Return dtbReport
      End Function
  </code></pre>
  
  <p>And here's my code when I click Run Report</p>
  
  <pre><code>Private Function FnGenerateReport() As String
      arrColumn(0) = 0
      arrColumn(1) = rm.intColumn1
      arrColumn(2) = rm.intColumn2
      arrColumn(3) = rm.intColumn3
      arrColumn(4) = rm.intColumn4
      arrColumn(5) = rm.intColumn5
      arrColumn(6) = rm.intColumn6
      arrColumn(7) = rm.intColumn7
      arrColumn(8) = rm.intColumn8
      arrColumn(9) = rm.intColumn9
      arrColumn(10) = rm.intColumn10
      arrColumn(11) = rm.intColumn11
      arrColumn(12) = rm.intColumn12
      arrColumn(13) = rm.intColumn13
      arrColumn(14) = rm.intColumn14
      arrColumn(15) = rm.intColumn15
      arrColumn(16) = rm.intColumn16
      arrColumn(17) = rm.intColumn17
      arrColumn(18) = rm.intColumn18
      arrColumn(19) = rm.intColumn19
      arrColumn(20) = rm.intColumn20
      arrColumn(21) = rm.intColumn21
      arrColumn(22) = rm.intColumn22
      arrColumn(23) = rm.intColumn23
      arrColumn(24) = rm.intColumn24
      arrColumn(25) = rm.intColumn25
      arrColumn(26) = rm.intColumn26
      arrColumn(27) = rm.intColumn27
  
      Dim strHTML As String = "&lt;table border=""1""&gt;&lt;tr&gt;"
  
      Dim dtbReport As DataTable = BLL.FnGenerateReport(rm)
      For intColCount As Int16 = 1 To 27
          If arrColumn(intColCount) = 1 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Applicant Name&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 2 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Job Applied for&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 3 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;EEO-1 Job Classification&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 4 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Date Applied&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 5 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Gender&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 6 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Race&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 7 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Source of Application&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 8 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Status of Application&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 9 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Date of Hire&lt;/strong&gt;&lt;/td&gt;&lt;"
          End If
          If arrColumn(intColCount) = 10 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Remarks&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 11 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Advertising Cost&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 12 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Time to Hire&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 13 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Division&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 14 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Location&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 15 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Job Title(Localised)&lt;/strong&gt; &lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 16 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Internal or External&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 17 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Recruiter&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 18 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Comments&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 19 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Job Code/Title&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 20 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Position Type&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 21 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Job Status&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 22 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Date Job Posted&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 23 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Job offer accepted Date&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 24 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;HC Classification&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 25 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Hourly/Salaried&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 26 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Ethnicity&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 27 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Disability Status&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 28 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Veteran Status&lt;/strong&gt;&lt;/td&gt;"
          End If
          If arrColumn(intColCount) = 29 Then
              strHTML += "&lt;td&gt;&lt;strong&gt;Requisition No.&lt;/strong&gt;&lt;/td&gt;"
          End If
      Next
      strHTML += "&lt;/tr&gt;"
  
      If dtbReport.Rows.Count &gt; 0 Then
          For Each dr As DataRow In dtbReport.Rows
              strHTML += "&lt;tr/&gt;"
              For intColCount2 As Int16 = 1 To 27
                  If arrColumn(intColCount2) = 1 Then
                      strHTML += "&lt;td&gt;&lt;a href=" &amp; strMainFolderName &amp; "Resume_Details.aspx?r=" &amp; dr("iResumeID") &amp; "&gt;" &amp; dr("vFirst") &amp; " " &amp; dr("vMiddle") &amp; " " &amp; dr("vLast") &amp; "&lt;/a&gt;&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 2 Then
                      strHTML += "&lt;td&gt;" &amp; dr("vGeneric") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 3 Then
                      strHTML += "&lt;td nowrap&gt;" &amp; dr("vJobClass") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 4 Then
                      strHTML += "&lt;td&gt;" &amp; dr("dtApply").ToShortDateString &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 5 Then
                      strHTML += "&lt;td&gt;" &amp; dr("vGender") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 6 Then
                      strHTML += "&lt;td&gt;" &amp; dr("vRace") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 7 Then
                      strHTML += "&lt;td&gt;"
                      If Not IsDBNull(dr("iChannelID")) Then
                          Dim strChannel As String = BLL.FnGetChannel(CInt(dr("iChannelID")))
                          strHTML += strChannel
                      End If
                      strHTML += "&amp;nbsp;&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 8 Then
                      strHTML += "&lt;td&gt;" &amp; dr("vHireStatus") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 9 Then
                      strHTML += "&lt;td&gt;"
                      If IsDate(dr("dtHire")) Then
                          strHTML += dr("dtHire").ToShortDateString
                      End If
                      strHTML += "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 10 Then
                      strHTML += "&lt;td&gt;" &amp; dr("Remarks") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 11 Then
                      strHTML += "&lt;td&gt;"
                      If Not IsDBNull(dr("ftAdCost")) Then
                          Replace(FormatNumber(dr("ftAdCost"), 2), ",", "")
                      End If
                      strHTML += "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 12 Then
                      strHTML += "&lt;td&gt;" &amp; dr("iTimeToHire") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 13 Then
                      strHTML += "&lt;td&gt;" &amp; dr("iDivisionID") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 14 Then
                      strHTML += "&lt;td&gt;" &amp; dr("vLocation") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 15 Then
                      strHTML += "&lt;td&gt;" &amp; dr("vLocalised") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 16 Then
                      strHTML += "&lt;td&gt;"
                      If (dr("blnEmployee")) = "True" Then
                          strHTML += "Internal"
                      Else
                          strHTML += "External"
                      End If
                      strHTML += "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 17 Then
                      strHTML += "&lt;td&gt;" &amp; dr("vFullName") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 18 Then
                      strHTML += "&lt;td&gt;" &amp; dr("Comments") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 19 Then
                      strHTML += "&lt;td&gt;" &amp; dr("JobCodeTitle") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 20 Then
                      strHTML += "&lt;td&gt;"
                      If (dr("PositionType")) = 1 Then
                          strHTML += "Full-Time"
                      ElseIf (dr("PositionType")) = 2 Then
                          strHTML += "Part-Time"
                      ElseIf (dr("PositionType")) = 3 Then
                          strHTML += "Internship"
                      End If
                      strHTML += "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 21 Then
                      strHTML += "&lt;td&gt;"
                      If dr("JobStatus") = 1 Then
                          strHTML += "Draft"
                      ElseIf dr("JobStatus") = 2 Then
                          strHTML += "Posted"
                      ElseIf dr("JobStatus") = 3 Then
                          strHTML += "Closed"
                      End If
                      strHTML += "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 22 Then
                      strHTML += "&lt;td&gt;"
                      If IsDate(dr("DateJobPosted")) Then
                          strHTML += dr("DateJobPosted").ToShortDateString
                      End If
                      strHTML += "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 23 Then
                      strHTML += "&lt;td&gt;"
                      If IsDate(dr("JobOfferAcceptedDate")) Then
                          strHTML += dr("JobOfferAcceptedDate").ToShortDateString
                      End If
                      strHTML += "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 24 Then
                      strHTML += "&lt;td&gt;" &amp; dr("ClassificationTitle") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 25 Then
                      strHTML += "&lt;td&gt;"
                      If dr("HourlySalaried") = 1 Then
                          strHTML += "Hourly"
                      ElseIf dr("HourlySalaried") = 2 Then
                          strHTML += "Salaried"
                      End If
                      strHTML += "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 26 Then
                      strHTML += "&lt;td&gt;" &amp; dr("vEthnicity") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 27 Then
                      strHTML += "&lt;td&gt;" &amp; dr("vDisability") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 28 Then
                      strHTML += "&lt;td&gt;" &amp; dr("vVeteran") &amp; "&lt;/td&gt;"
                  End If
                  If arrColumn(intColCount2) = 29 Then
                      strHTML += "&lt;td&gt;" &amp; dr("vRequisition") &amp; "&lt;/td&gt;"
                  End If
              Next
              strHTML += "&lt;/tr&gt;"
          Next
      End If
      strHTML += "&lt;/table&gt;"
      Return strHTML
  End Function
  </code></pre>