我要添加部分的一个ASP.NET 应用程序(VB.NET 代码隐藏),这将允许用户获取数据,返回到他们作为一个Excel文件,我将产生基于数据库的数据。虽然有几种方式这样做的,每个人都有自己的缺点。怎么会 你的 返回的数据?我在寻找东西是作为干净的和直接的成为可能。

有帮助吗?

解决方案

CSV

赞成:

  • 简单的

缺点:

  • 它可能不在其他区域或在不同的Excel配置(即列表中分离器)
  • 不能应用的格式化,公式,等等

HTML

赞成:

  • 仍然相当简单
  • 支持简单的格式和公式

缺点:

  • 你有名字的文件如xls和Excel可能警告你关于开放一个非本地Excel文件
  • 一个工作表的每个工作簿

心(办公室2007年。您)

赞成:

  • 本机Excel格式
  • 支持所有Excel功能
  • 不不 需要 一个安装复制的Excel
  • 可以产生枢表
  • 可产生使用开放源码项目 EPPlus

缺点:

  • 有限的兼容性以外的Excel2007年(不应该是一个问题如今)
  • 复杂的,除非你使用一个三方组件

SpreadSheetML(开放的XML格式)

赞成:

  • 简单相比,本地Excel格式
  • 支持最Excel功能:格式化、风格、公式、多张每个工作簿
  • Excel不需要安装使用它
  • 没有第三方的图书馆需要-只要写出你的xml
  • 文件可以打开的Excel XP/2003/2007年

缺点:

  • 缺乏良好的文件
  • 不支持在旧版本的Excel(pre-2000年)
  • 只写的,在这一次你打开它,做出更改,Excel这是转换为当地Excel。

XLS(所产生的由第三方分量)

赞成:

  • 产生本机Excel文件与所有格式化,公式,等等。

缺点:

  • 花钱
  • 添加依赖关系

COM互操作

赞成:

  • 使用机Microsoft库
  • 阅读支持本地的文件

缺点:

  • 非常慢
  • 依赖/版本匹配的问题
  • 并发性/数据完整性问题网络时使用的阅读
  • 非常慢
  • 扩展问题对使用网络(不同于并发):需要创造许多情况下的沉重的Excel应用程序服务器上
  • 需要Windows
  • 我说过,它的缓慢?

其他提示

您可以将数据输出为html表格单元格,在其上粘贴 .xls .xlsx 扩展名,Excel将打开它,就像它是本机文档一样。您甚至可以通过这种方式进行有限的格式化和公式计算,因此它比CSV更强大。此外,从ASP.Net等网络平台输出html表应该很容易;)

如果在Excel工作簿中需要多个工作表或命名工作表,则可以通过名为 SpreadSheetML 的XML模式执行类似的操作。这是 Office 2007附带的新格式,但是与Excel 2000一样完全不同的东西。解释它如何工作的最简单方法是使用示例:

<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?> 
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
        xmlns:o="urn:schemas-microsoft-com:office:office"
        xmlns:x="urn:schemas-microsoft-com:office:excel"
        xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
        xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
      <Author>Your_name_here</Author>
      <LastAuthor>Your_name_here</LastAuthor>
      <Created>20080625</Created>
      <Company>ABC Inc</Company>
      <Version>10.2625</Version>
</DocumentProperties>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
        <WindowHeight>6135</WindowHeight>
        <WindowWidth>8445</WindowWidth>
        <WindowTopX>240</WindowTopX>
        <WindowTopY>120</WindowTopY>
        <ProtectStructure>False</ProtectStructure>
        <ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>

<Styles>
      <Style ss:ID="Default" ss:Name="Normal">
            <Alignment ss:Vertical="Bottom" />
            <Borders />
            <Font />
            <Interior />
            <NumberFormat />
            <Protection />
      </Style>
</Styles>

<Worksheet ss:Name="Sample Sheet 1">
<Table ss:ExpandedColumnCount="2" x:FullColumns="1" x:FullRows="1" ID="Table1">
<Column ss:Width="150" />
<Column ss:Width="200" />
<Row>
      <Cell><Data ss:Type="Number">1</Data></Cell>
      <Cell><Data ss:Type="Number">2</Data></Cell>
</Row>
<Row>
      <Cell><Data ss:Type="Number">3</Data></Cell>
      <Cell><Data ss:Type="Number">4</Data></Cell>
</Row>
<Row>
      <Cell><Data ss:Type="Number">5</Data></Cell>
      <Cell><Data ss:Type="Number">6</Data></Cell>
</Row>
<Row>
      <Cell><Data ss:Type="Number">7</Data></Cell>
      <Cell><Data ss:Type="Number">8</Data></Cell>
</Row>
</Table>
</Worksheet>

<Worksheet ss:Name="Sample Sheet 2">
<Table ss:ExpandedColumnCount="2" x:FullColumns="1" x:FullRows="1" ID="Table2">
<Column ss:Width="150" />
<Column ss:Width="200" />
<Row>
      <Cell><Data ss:Type="String">A</Data></Cell>
      <Cell><Data ss:Type="String">B</Data></Cell>
</Row>
<Row>
      <Cell><Data ss:Type="String">C</Data></Cell>
      <Cell><Data ss:Type="String">D</Data></Cell>
</Row>
<Row>
      <Cell><Data ss:Type="String">E</Data></Cell>
      <Cell><Data ss:Type="String">F</Data></Cell>
</Row>
<Row>
      <Cell><Data ss:Type="String">G</Data></Cell>
      <Cell><Data ss:Type="String">H</Data></Cell>
</Row>
</Table>
</Worksheet>
</Workbook> 

如果来自 DataTable

public static void DataTabletoXLS(DataTable DT, string fileName)
{
    HttpContext.Current.Response.Clear();
    HttpContext.Current.Response.Charset = "utf-16";
    HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250");
    HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}.xls", fileName));
    HttpContext.Current.Response.ContentType = "application/ms-excel";

    string tab = "";
    foreach (DataColumn dc in DT.Columns)
    {
        HttpContext.Current.Response.Write(tab + dc.ColumnName.Replace("\n", "").Replace("\t", ""));
        tab = "\t";
    }
    HttpContext.Current.Response.Write("\n");

    int i;
    foreach (DataRow dr in DT.Rows)
    {
        tab = "";
        for (i = 0; i < DT.Columns.Count; i++)
        {
            HttpContext.Current.Response.Write(tab + dr[i].ToString().Replace("\n", "").Replace("\t", ""));
            tab = "\t";
        }
        HttpContext.Current.Response.Write("\n");
    }
    HttpContext.Current.Response.End();
}

来自 Gridview

public static void GridviewtoXLS(GridView gv, string fileName)
{
    int DirtyBit = 0;
    int PageSize = 0;
    if (gv.AllowPaging == true)
    {
        DirtyBit = 1;
        PageSize = gv.PageSize;
        gv.AllowPaging = false;
        gv.DataBind();
    }

    HttpContext.Current.Response.Clear();
    HttpContext.Current.Response.Charset = "utf-8";
    HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250");
    HttpContext.Current.Response.AddHeader(
        "content-disposition", string.Format("attachment; filename={0}.xls", fileName));
    HttpContext.Current.Response.ContentType = "application/ms-excel";

    using (StringWriter sw = new StringWriter())
    using (HtmlTextWriter htw = new HtmlTextWriter(sw))
    {
        //  Create a table to contain the grid
        Table table = new Table();

        //  include the gridline settings
        table.GridLines = gv.GridLines;

        //  add the header row to the table
        if (gv.HeaderRow != null)
        {
            Utilities.Export.PrepareControlForExport(gv.HeaderRow);
            table.Rows.Add(gv.HeaderRow);
        }

        //  add each of the data rows to the table
        foreach (GridViewRow row in gv.Rows)
        {
            Utilities.Export.PrepareControlForExport(row);
            table.Rows.Add(row);
        }

        //  add the footer row to the table
        if (gv.FooterRow != null)
        {
            Utilities.Export.PrepareControlForExport(gv.FooterRow);
            table.Rows.Add(gv.FooterRow);
        }

        //  render the table into the htmlwriter
        table.RenderControl(htw);

        //  render the htmlwriter into the response
        HttpContext.Current.Response.Write(sw.ToString().Replace("£", ""));
        HttpContext.Current.Response.End();
    }

    if (DirtyBit == 1)
    {
        gv.PageSize = PageSize;
        gv.AllowPaging = true;
        gv.DataBind();
    }
}

private static void PrepareControlForExport(Control control)
{
    for (int i = 0; i < control.Controls.Count; i++)
    {
        Control current = control.Controls[i];
        if (current is LinkButton)
        {
            control.Controls.Remove(current);
            control.Controls.AddAt(i, new LiteralControl((current as LinkButton).Text));
        }
        else if (current is ImageButton)
        {
            control.Controls.Remove(current);
            control.Controls.AddAt(i, new LiteralControl((current as ImageButton).AlternateText));
        }
        else if (current is HyperLink)
        {
            control.Controls.Remove(current);
            control.Controls.AddAt(i, new LiteralControl((current as HyperLink).Text));
        }
        else if (current is DropDownList)
        {
            control.Controls.Remove(current);
            control.Controls.AddAt(i, new LiteralControl((current as DropDownList).SelectedItem.Text));
        }
        else if (current is CheckBox)
        {
            control.Controls.Remove(current);
            control.Controls.AddAt(i, new LiteralControl((current as CheckBox).Checked ? "True" : "False"));
        }

        if (current.HasControls())
        {
            Utilities.Export.PrepareControlForExport(current);
        }
    }
}

这是一个围绕SpreadML的免费包装器 - 它运行良好。

http://www.carlosag.net/Tools/ExcelXmlWriter/

根据给出的答案以及与同事协商,最佳解决方案似乎是生成XML文件或HTML表格并将其作为附件下推。我的同事推荐的一个改变是数据(即HTML表)可以直接写入Response对象,因此无需写出文件,由于权限问题,I / O可能会很麻烦争用,并确保发生计划的清除。

这是代码的片段......我还没有检查过这个,我还没有提供所有被调用的代码,但我认为它代表了这个想法。

    Dim uiTable As HtmlTable = GetUiTable(groupedSumData)

    Response.Clear()

    Response.ContentType = "application/vnd.ms-excel"
    Response.AddHeader("Content-Disposition", String.Format("inline; filename=OSSummery{0:ddmmssf}.xls", DateTime.Now))

    Dim writer As New System.IO.StringWriter()
    Dim htmlWriter As New HtmlTextWriter(writer)
    uiTable.RenderControl(htmlWriter)
    Response.Write(writer.ToString)

    Response.End()

由于Excel理解HTML,您只需将数据作为HTML表格写入扩展名为.xls的临时文件,获取文件的FileInfo,然后使用

将其反吹。
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fi.Name);
Response.AddHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(fi.FullName);
Response.End();

如果你想避开临时文件,你可以写入内存中的流并写回字节而不是使用WriteFile

如果省略了content-length标题,你可以直接写回html,但这可能无法在所有浏览器中一直正常工作

我个人更喜欢XML方法。我将从数据集中的数据库中返回数据,将其保存到XMl,然后创建一个xslt文件,其中包含将格式化正确文档的转换规则,并且简单的XML转换将完成作业。关于此的最佳部分,您可以格式化单元格,进行条件格式设置,设置页眉和页脚,甚至设置打印范围。

我已经完成了几次,每次最简单的方法就是返回一个CSV(逗号分隔值)文件。 Excel完美地导入它,并且它的速度相对较快。

我们的出口数据从一种数据表格,以excel所有的时间。转换到HTML然后写到excel文件

Response.ContentType = "application/vnd.ms-excel"
    Response.Charset = ""
    Response.AddHeader("content-disposition", "fileattachment;filename=YOURFILENAME.xls")
    Me.EnableViewState = False
    Dim sw As System.IO.StringWriter = New System.IO.StringWriter
    Dim hw As HtmlTextWriter = New HtmlTextWriter(sw)
    ClearControls(grid)
    grid.RenderControl(hw)
    Response.Write(sw.ToString())
    Response.End()

只有你用这种方法是,很多我们的网格,有的按钮或链接在他们所以你需要这个的:

'needed to export grid to excel to remove link button control and represent as text
Private Sub ClearControls(ByVal control As Control)
    Dim i As Integer
    For i = control.Controls.Count - 1 To 0 Step -1
        ClearControls(control.Controls(i))
    Next i

    If TypeOf control Is System.Web.UI.WebControls.Image Then
        control.Parent.Controls.Remove(control)
    End If

    If (Not TypeOf control Is TableCell) Then
        If Not (control.GetType().GetProperty("SelectedItem") Is Nothing) Then
            Dim literal As New LiteralControl
            control.Parent.Controls.Add(literal)
            Try
                literal.Text = CStr(control.GetType().GetProperty("SelectedItem").GetValue(control, Nothing))
            Catch
            End Try
            control.Parent.Controls.Remove(control)
        Else
            If Not (control.GetType().GetProperty("Text") Is Nothing) Then
                Dim literal As New LiteralControl
                control.Parent.Controls.Add(literal)
                literal.Text = CStr(control.GetType().GetProperty("Text").GetValue(control, Nothing))
                control.Parent.Controls.Remove(control)
            End If
        End If
    End If
    Return
End Sub

我发现在某个地方,它工作得很好。

我建议免费开源excel生成libruary ,它基于OpenXML

几个月前它帮助了我。

这是一个从存储过程中提取的报告。结果将导出到Excel。 它使用ADO而不是ADO.NET,原因是这一行

oSheet.Cells(2, 1).copyfromrecordset(rst1)

它执行大部分工作,但在ado.net中不可用。

‘Calls stored proc in SQL Server 2000 and puts data in Excel and ‘formats it

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim cnn As ADODB.Connection
        cnn = New ADODB.Connection
        cnn.Open("Provider=SQLOLEDB;data source=xxxxxxx;" & _
          "database=xxxxxxxx;Trusted_Connection=yes;")

        Dim cmd As New ADODB.Command


        cmd.ActiveConnection = cnn


        cmd.CommandText = "[sp_TomTepley]"
        cmd.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc
        cmd.CommandTimeout = 0
        cmd.Parameters.Refresh()


        Dim rst1 As ADODB.Recordset
        rst1 = New ADODB.Recordset
        rst1.Open(cmd)

        Dim oXL As New Excel.Application
        Dim oWB As Excel.Workbook
        Dim oSheet As Excel.Worksheet

        'oXL = CreateObject("excel.application")
        oXL.Visible = True
        oWB = oXL.Workbooks.Add
        oSheet = oWB.ActiveSheet

        Dim Column As Integer
        Column = 1

        Dim fld As ADODB.Field
        For Each fld In rst1.Fields

            oXL.Workbooks(1).Worksheets(1).Cells(1, Column).Value = fld.Name
            oXL.Workbooks(1).Worksheets(1).cells(1, Column).Interior.ColorIndex = 15
            Column = Column + 1

        Next fld

        oXL.Workbooks(1).Worksheets(1).name = "Tom Tepley Report"
        oSheet.Cells(2, 1).copyfromrecordset(rst1)
        oXL.Workbooks(1).Worksheets(1).Cells.EntireColumn.AutoFit()


        oXL.Visible = True
        oXL.UserControl = True

        rst1 = Nothing

        cnn.Close()
        Beep()

    End Sub

如果用数据填充GridView,可以使用此函数获取HTML格式的数据,但指示浏览器是excel文件。

 Public Sub ExportToExcel(ByVal fileName As String, ByVal gv As GridView)

        HttpContext.Current.Response.Clear()
        HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fileName))
        HttpContext.Current.Response.ContentType = "application/ms-excel"

        Dim sw As StringWriter = New StringWriter
        Dim htw As HtmlTextWriter = New HtmlTextWriter(sw)
        Dim table As Table = New Table

        table.GridLines = gv.GridLines

        If (Not (gv.HeaderRow) Is Nothing) Then
            PrepareControlForExport(gv.HeaderRow)
            table.Rows.Add(gv.HeaderRow)
        End If

        For Each row As GridViewRow In gv.Rows
            PrepareControlForExport(row)
            table.Rows.Add(row)
        Next

        If (Not (gv.FooterRow) Is Nothing) Then
            PrepareControlForExport(gv.FooterRow)
            table.Rows.Add(gv.FooterRow)
        End If

        table.RenderControl(htw)

        HttpContext.Current.Response.Write(sw.ToString)
        HttpContext.Current.Response.End()

    End Sub


    Private Sub PrepareControlForExport(ByVal control As Control)

        Dim i As Integer = 0

        Do While (i < control.Controls.Count)

            Dim current As Control = control.Controls(i)

            If (TypeOf current Is LinkButton) Then
                control.Controls.Remove(current)
                control.Controls.AddAt(i, New LiteralControl(CType(current, LinkButton).Text))

            ElseIf (TypeOf current Is ImageButton) Then
                control.Controls.Remove(current)
                control.Controls.AddAt(i, New LiteralControl(CType(current, ImageButton).AlternateText))

            ElseIf (TypeOf current Is HyperLink) Then
                control.Controls.Remove(current)
                control.Controls.AddAt(i, New LiteralControl(CType(current, HyperLink).Text))

            ElseIf (TypeOf current Is DropDownList) Then
                control.Controls.Remove(current)
                control.Controls.AddAt(i, New LiteralControl(CType(current, DropDownList).SelectedItem.Text))

            ElseIf (TypeOf current Is CheckBox) Then
                control.Controls.Remove(current)
                control.Controls.AddAt(i, New LiteralControl(CType(current, CheckBox).Checked))

            End If

            If current.HasControls Then
                PrepareControlForExport(current)
            End If

            i = i + 1

        Loop

    End Sub

通过Microsoft.Office.Interop命名空间避免COM Interop。它是如此缓慢,不可靠和不可扩展。不适用于受虐狂者。

您可以使用此库轻松创建格式精美的Excel文件: http://officehelper.codeplex.com/文档

不需要在网络服务器上安装Microsoft Office!

CSV是最简单的方法。大部分时间它都链接到Excel。否则,您必须使用自动化API或XML格式。 API和XML并不难以使用。

有关为Excel生成XML的信息

我要么采用CSV路由(如上所述),要么更常见,我使用Infragistics NetAdvantage生成文件。 (在Infragistics正在运行的绝大多数时间里,我们只是导出一个现有的UltraWebGrid,它本质上是一个LOC解决方案,除非需要额外的格式调整。我们也可以手动生成Excel / BIFF文件,但很少需要。)

man,在.net中我想你可以有一个组件可以做到这一点,但在经典的asp我已经完成了创建一个html表并将页面的mime tipe更改为vnd / msexcel。我想如果你使用gridview并更改mime类型,它可能会起作用,因为gridview是一个html表。

避免“看起来像这些数字存储为文本”的唯一防弹方式绿色三角形是使用Open XML格式。值得使用它,只是为了避免不可避免的绿色三角形。

我见过的excel报告的最佳方法是使用XML扩展以XML格式写出数据并将其流式传输到具有正确内容类型的客户端。 (应用/ XLS)

这适用于任何需要基本格式化的报告,并允许您使用文本比较工具与现有电子表格进行比较。

假设这是一个Intranet,您可以在其中设置权限并授权IE,您可以使用 JScript / VBScript驱动Excel 。这为您提供了原生的Excel格式,没有尝试在服务器上自动化Excel的麻烦。

我不确定我是否真的会推荐这种方法,除非在相当小的情况下,但在经典的ASP鼎盛时期它是相当普遍的。

您当然可以选择第三方组件。就个人而言,我对Spire.XLS有很好的体验 http://www.e- iceblue.com/xls/xlsintro.htm

该组件在您的应用程序中非常易于使用:

        Workbook workbook = new Workbook();

        //Load workbook from disk.
        workbook.LoadFromFile(@"Data\EditSheetSample.xls");
        //Initailize worksheet
        Worksheet sheet = workbook.Worksheets[0];

        //Writes string
        sheet.Range["B1"].Text = "Hello,World!";
        //Writes number
        sheet.Range["B2"].NumberValue = 1234.5678;
        //Writes date
        sheet.Range["B3"].DateTimeValue = System.DateTime.Now;
        //Writes formula
        sheet.Range["B4"].Formula = "=1111*11111";

        workbook.SaveToFile("Sample.xls");

我使用上述建议的解决方案遇到的一个问题类似于这个答案推送Excel内容,如果你将内容作为附件推出(我发现这是非ms浏览器最干净的解决方案),然后在Excel 2000-2003中打开它,它的类型是“Excel网页”。而不是本机Excel文档。

然后你必须向用户解释如何使用“另存为类型”从Excel中将其转换为Excel文档。如果用户需要编辑此文档,然后将其重新上传到您的网站,则会很麻烦。

我的建议是使用CSV。这很简单,如果用户在Excel中打开它,Excel至少会提示他们以原生格式保存它。

我只是根据数据创建一个CSV文件,因为我认为它是最干净的,Excel对它有很好的支持。但是如果你需要更灵活的格式,我相信有一些第三方工具可以生成真正的excel文件。

这是一个将数据流作为CSV流出的解决方案。快速,干净,简单,它在输入中处理逗号。

public static void ExportToExcel(DataTable data, HttpResponse response, string fileName)
{
    response.Charset = "utf-8";
    response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250");
    response.Cache.SetCacheability(HttpCacheability.NoCache);
    response.ContentType = "text/csv";
    response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);

    for (int i = 0; i < data.Columns.Count; i++)
    {
       response.Write(data.Columns[i].ColumnName);
       response.Write(i == data.Columns.Count - 1 ? "\n" : ",");
    }        
    foreach (DataRow row in data.Rows)
    {
        for (int i = 0; i < data.Columns.Count; i++)
        {
            response.Write(String.Format("\"{0}\"", row[i].ToString()));
            response.Write(i == data.Columns.Count - 1 ? "\n" : ",");
        }
    }

    response.End();
}

刚刚创建了一个从Web表单C#导出到excel希望它能帮助其他人的功能

    public void ExportFileFromSPData(string filename, DataTable dt)
    {
        HttpResponse response = HttpContext.Current.Response;

        //clean up the response.object
        response.Clear();
        response.Buffer = true;
        response.Charset = "";

        // set the response mime type for html so you can see what are you printing 
        //response.ContentType = "text/html";
        //response.AddHeader("Content-Disposition", "attachment;filename=test.html");

        // set the response mime type for excel
        response.ContentType = "application/vnd.ms-excel";
        response.AddHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");
        response.ContentEncoding = System.Text.Encoding.UTF8;
        response.BinaryWrite(System.Text.Encoding.UTF8.GetPreamble());

        //style to format numbers to string
        string style = @"<style> .text { mso-number-format:\@; } </style>";
        response.Write(style);

        // create a string writer
        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter htw = new HtmlTextWriter(sw))
            {
                // instantiate a datagrid
                GridView dg = new GridView();
                dg.DataSource = dt;
                dg.DataBind();

                foreach (GridViewRow datarow in dg.Rows)
                {
                    //format specific cell to be text 
                    //to avoid 1.232323+E29 to get 1232312312312312124124
                    datarow.Cells[0].Attributes.Add("class", "text");
                }

                dg.RenderControl(htw);
                response.Write(sw.ToString());
                response.End();
            }
        }
     }

如果你有使用Excel而不是CSV文件,你会需要使用OLE自动化上的Excel的实例之一的服务器。最简单的方法来做到这一点是有一个模板的文件和编程方式填写的数据。你保存它的另一个文件。

提示:

  • 不这样做以交互方式。有用户开始的进程,然后后一页带有链接到该文件。这减少了潜在的效能问题,同时电子表格产生的。
  • 使用的模板,因为我描述过了。它可以更容易地进行修改。
  • 确保Excel设置为不流行了对话。在网络服务器,这将挂整个excel的实例。
  • 保持Excel的实例在单独的服务器上,最好的防火墙后面,所以它不是作为一个潜在的安全漏洞。
  • 眼睛保持对资源使用情况。产生spreadhseet过OLE自动化接口(PIA的只是填充了这一)是一个相当重量级的进程。如果你需要扩大这个高数据容量可能需要点聪明的架构。

一些使用mime-类型欺骗excel入开HTML table'办法将会工作如果你不介意的文件的格式一点的基础。这些办法也fob CPU繁重的工作到客户。如果你想要的细graned控制的格式电子表格你可能会有使用Excel本身产生的文件如上文所述。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top