Protected Sub BtnExportExcel_Click(sender As Object, e As EventArgs) Handles BtnExportExcel.Click
Dim license As New License()
license.SetLicense(LicenseHelper.License.LStream)
Dim XlsRow As Integer
Dim tmpFileName As String
tmpFileName = "../Designer/TemAgreement/BarcodeBIO.xlsx"
Dim sqlquery As String = "select fxa_id,left(fxa_name,25) as fxa_name,REPLACE(fxa_id,'FA','') as fxa_serial from TRFAAgreementDetail left outer join TRFAAgreement on fmd_fam_id=fam_id"
sqlquery += " left outer join TRFixedAssets on fmd_fxa_id=fxa_id where fam_id= '" + lbl_id.Text + "' order by fxa_id"
'Response.Write(sqlquery)
'Response.End()
Dim sql As New SqlCommand(sqlquery, connect)
connect.Open()
dr = sql.ExecuteReader()
Dim Workbook As New Workbook(Server.MapPath(tmpFileName))
Dim Sheet As Worksheet
For Each Sheet In Workbook.Worksheets
Dim i As Integer = 1
If Sheet.Name = "DATA" Then
XlsRow = 3
While dr.Read()
Sheet.Cells(XlsRow, 0).PutValue(i, +i)
Sheet.Cells(XlsRow, 1).PutValue(dr("fxa_id"))
Sheet.Cells(XlsRow, 2).PutValue(dr("fxa_name"))
Sheet.Cells(XlsRow, 3).PutValue(dr("fxa_serial"))
XlsRow += 1
i += 1
End While
End If
Next
connect.Close()
Workbook.Save(HttpContext.Current.Response, "BarcodeBIO.xlsx", ContentDisposition.Attachment, New XlsSaveOptions(SaveFormat.Xlsx))
Sheet = Nothing
Workbook = Nothing
End Sub