如何在excel中查看的html表中显示尾随零?
我已经检查过记事本++中的html,所以我知道它们就在那里。
该表正在.ashx中构建,扩展名为.xls。
细节
我希望为用户自动格式化数字。
我仍然希望能够将数字操作为数字(如果显示为文本)。
我如何在ashx中构建表格
If sqlDataset.Tables(0).Rows.Count > 0 Then
context.Response.BufferOutput = False
Dim response As HttpResponse = context.Response
context.Response.AddHeader("content-disposition", "attachment; filename=Total Quote Sheet " & DateTime.Now() & ".xls")
context.Response.ContentType = "application/ms-excel"
Dim outputHTML As String
Using sw As StringWriter = New StringWriter
Using ht As HtmlTextWriter = New HtmlTextWriter(sw)
Dim table As New Table
Dim headings = {"Article Number", "Quantity Quote", "SAP Supplier #", "Cost Code", "Unit Cost", "Extended Cost", "SAP Description", "Status"}
Dim HeaderRow As New TableRow
HeaderRow.ForeColor = Drawing.Color.White
For Each heading As String In headings
Dim Cell As New TableCell
Cell.Text = heading
Cell.BorderWidth = 1
Cell.BorderColor = Drawing.Color.Black
Cell.BorderStyle = BorderStyle.Solid
Cell.BackColor = System.Drawing.ColorTranslator.FromHtml("#003797")
HeaderRow.Cells.Add(Cell)
Next
table.Rows.Add(HeaderRow)
For u As Integer = 0 To sqlDataset.Tables(0).Rows.Count - 1
Dim DataRow As New TableRow
Dim dataColumnNames = {"AN", "QB", "SSN", "CC", "UC", "EC", "AD", "BAI"}
For Each dataColumnName As String In dataColumnNames
Dim Cell As New TableCell
Cell.Text = sqlDataset.Tables(0).Rows(u).Field(Of Object)(dataColumnName)
Cell.BorderWidth = 1
Cell.BorderColor = Drawing.Color.Black
Cell.BorderStyle = BorderStyle.Solid
If dataColumnName = "BAI" Then
Select Case sqlDataset.Tables(0).Rows(u).Field(Of Object)(dataColumnName)
Case "U"
Cell.Text = "Undecided"
Case "A"
Cell.Text = "Accepted"
Case "R"
Cell.Text = "Rejected"
End Select
End If
DataRow.Cells.Add(Cell)
Next
table.Rows.Add(DataRow)
Next
table.RenderControl(ht)
outputHTML = sw.ToString()
context.Response.Write(outputHTML)
End Using
End Using
End If
答案 0 :(得分:0)
您需要将值显示为文本。有三种方法可以做到这一点,一种是将单元格格式设置为文本,使用text()函数,或者如果要导入它,则可以将数据类型更改为文本。