导出

时间:2017-03-10 06:24:44

标签: asp.net excel vb.net export-to-excel

我有一个应用程序,当我单击“运行报告”按钮时,它将生成数据并将导出为ex​​cel。

我的问题是,我在列中有一个数据是申请编号,例如此列的值就像这个08-20但是当我在excel上导出它时它将成为一个日期{ {1}}

Excel

请理解我已经搜索了解决方案。我看到一个类似于我的问题,但我没有网格视图,当我点击运行报告时,它会自动生成数据,然后导出。

修改

这是20-Aug

fnGeneratereport的代码
DAL

点击“运行报告”

,这是我的代码
  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) > 0 And rm.intCountry <> 0 Then
            strQuery.Append("AND J.iCountryID=@CountryID ")
        End If
        If Len(rm.intDivisionID) > 0 And rm.intDivisionID <> 0 Then
            strQuery.Append("AND J.iDivisionID=@DivisionID ")
        End If
        If Len(rm.strLocation) > 0 Then
            strQuery.Append("AND J.vLocation LIKE @Location ")
        End If
        If Len(rm.dtePostFrom) > 0 Then
            strQuery.Append("AND R.dtApply>=@PostFrom ")
        End If
        If Len(rm.dtePostTo) > 0 Then
            strQuery.Append("AND R.dtApply<=@PostTo ")
            strQuery.Append("AND J.dtPost<=@PostTo ")
        End If
        If Len(rm.strRequisition) > 0 Then
            strQuery.Append("AND J.vRequisition LIKE @Requisition ")
        End If
        If Len(rm.intHireStatus) > 0 And rm.intHireStatus <> 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 <> 0 Then
            strQuery.Append("AND J.iJobStatus=@JobStatus ")
        End If
        If Len(rm.dteJobPostFrom) > 0 Then
            strQuery.Append("AND J.dtPost>=@JobPostFrom ")
        End If
        If Len(rm.dteJobPostTo) > 0 Then
            strQuery.Append("AND J.dtPost<=@JobPostTo ")
        End If

        Return dtbReport
    End Function

1 个答案:

答案 0 :(得分:0)

您是否尝试过将正手栏的设置更改为文字或数字? 如果您可以在开始工具栏中标记整列,则更改列的格式。您可以在标准,日期,测试等的下拉菜单中进行选择。