Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 使excel在html表格中显示尾随的零_.net_Excel_Html Table_Zero - Fatal编程技术网

.net 使excel在html表格中显示尾随的零

.net 使excel在html表格中显示尾随的零,.net,excel,html-table,zero,.net,Excel,Html Table,Zero,如何在excel中查看的html表格中显示尾随的零 我已经用notepad++检查了html,所以我知道它们在那里 该表正在.ashx中构建,扩展名为.xls 细节 我想为用户自动设置数字格式 我希望仍然能够将数字作为数字进行操作(如果显示为文本) 我如何在ashx中构建表格 If sqlDataset.Tables(0).Rows.Count > 0 Then context.Response.BufferOutput = False Dim response As Ht

如何在excel中查看的html表格中显示尾随的零

我已经用notepad++检查了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

您需要将值显示为文本。有三种方法可以做到这一点,一种是将单元格格式设置为text,使用text()函数,或者如果要导入,可以将数据类型更改为text。

对不起,我应该更具体一些。我希望这是自动为用户(客户端)。另外,我可以在html表格中使用
text()
函数吗?如果是这样的话,这些数字还能被当作数字处理吗?那么,如果我是客户,我是在打开你的电子表格,还是只是在制作自己的电子表格并导入你的数据?不,我不认为你可以把一个Excel公式和Excel导入它作为一个公式,但是如果你把一个字符放在你的数字之前,它会考虑它的文本,尽管它可能仍然显示字符使用<代码> HTTPHandler <代码>来生成一个HTML表。我只是简单地添加了一个
.xls
扩展名。用户在excel中自动打开html表,并可以从中进行操作。它看起来就像一个真正的excel电子表格,除了一个可笑的警告,我不知道如何关闭。是的,很遗憾,但这实际上是微软推荐的excel导出方法。他们实际上建议不要使用内置的excel库来构建真正的excel文件。你能把你的东西贴出来让我明白你的意思吗?