Excel で表示される HTML テーブルの末尾のゼロを表示するにはどうすればよいですか?
メモ帳++でhtmlを調べたので、そこにあることがわかりました。
テーブルは、拡張子が .xls の .ashx で作成されています。
詳細
ユーザー向けに数値を自動的にフォーマットしたいと思います。
数値を数値として操作できるようにしたいと思います(テキストとして表示する場合)。
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