• <i id='iBDiG'><tr id='iBDiG'><dt id='iBDiG'><q id='iBDiG'><span id='iBDiG'><b id='iBDiG'><form id='iBDiG'><ins id='iBDiG'></ins><ul id='iBDiG'></ul><sub id='iBDiG'></sub></form><legend id='iBDiG'></legend><bdo id='iBDiG'><pre id='iBDiG'><center id='iBDiG'></center></pre></bdo></b><th id='iBDiG'></th></span></q></dt></tr></i><div id='iBDiG'><tfoot id='iBDiG'></tfoot><dl id='iBDiG'><fieldset id='iBDiG'></fieldset></dl></div>

      <bdo id='iBDiG'></bdo><ul id='iBDiG'></ul>
    <tfoot id='iBDiG'></tfoot>

    <legend id='iBDiG'><style id='iBDiG'><dir id='iBDiG'><q id='iBDiG'></q></dir></style></legend>

        <small id='iBDiG'></small><noframes id='iBDiG'>

      1. 将自定义标题添加到 excel 文件

        时间:2023-08-26

          <legend id='INMJ4'><style id='INMJ4'><dir id='INMJ4'><q id='INMJ4'></q></dir></style></legend>
            <tbody id='INMJ4'></tbody>
            • <small id='INMJ4'></small><noframes id='INMJ4'>

              <i id='INMJ4'><tr id='INMJ4'><dt id='INMJ4'><q id='INMJ4'><span id='INMJ4'><b id='INMJ4'><form id='INMJ4'><ins id='INMJ4'></ins><ul id='INMJ4'></ul><sub id='INMJ4'></sub></form><legend id='INMJ4'></legend><bdo id='INMJ4'><pre id='INMJ4'><center id='INMJ4'></center></pre></bdo></b><th id='INMJ4'></th></span></q></dt></tr></i><div id='INMJ4'><tfoot id='INMJ4'></tfoot><dl id='INMJ4'><fieldset id='INMJ4'></fieldset></dl></div>

              <tfoot id='INMJ4'></tfoot>
                • <bdo id='INMJ4'></bdo><ul id='INMJ4'></ul>

                  本文介绍了将自定义标题添加到 excel 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  在 ASP.NET 中将 DataSet 导出到 Excel 时,是否可以向 Excel 添加自定义标题?我有一个这样的要求.我可以成功地将 DataSet 导出到 Excel.但我无法添加自定义标题.如果有人有解决方案,请帮助我.提前致谢.

                  Is it possible to add a custom header to the Excel while exporting a DataSet to Excel in ASP.NET? I have one requirement like this. I can export the DataSet to the Excel successfully. But I can't add the custom header. Please help me if anybody have the solution. Thanks in advance.

                  推荐答案

                  如果您使用 Response.Write 导出 Excel.您可以毫不费力地使用以下代码,并且可以根据需要自定义 Header,就像 HTML 标头一样.

                  IF you are using Response.Write to Export the Excel. You can use the following code with minimal effort and the Header can be customized as you want, just like HTML headers.

                  Response.ContentType = "application/vnd.ms-excel";
                  Response.AddHeader("Content-Disposition", "attachment; filename=test.xls;");                
                  StringWriter stringWrite = new StringWriter();        
                  HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);        
                  dgrExport.DataSource = dtExport;        
                  dgrExport.DataBind();
                  dgrExport.RenderControl(htmlWrite);
                  string headerTable = @"<Table><tr><td>Report Header</td></tr><tr><td><img src=""D:\Folder\Report Header.jpg"" ></td></tr></Table>";
                  Response.Write(headerTable);
                  Response.Write(stringWrite.ToString());        
                  Response.End();
                  

                  Mac,你也在寻找同样的东西吗?

                  Mac, Are you looking for the same?

                  这篇关于将自定义标题添加到 excel 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:为 C# 中的所有请求向 Webbrowser 控件添加自定义标 下一篇:正则表达式解析 C/C++ 函数声明

                  相关文章

                  最新文章

                    <bdo id='j28C7'></bdo><ul id='j28C7'></ul>
                • <i id='j28C7'><tr id='j28C7'><dt id='j28C7'><q id='j28C7'><span id='j28C7'><b id='j28C7'><form id='j28C7'><ins id='j28C7'></ins><ul id='j28C7'></ul><sub id='j28C7'></sub></form><legend id='j28C7'></legend><bdo id='j28C7'><pre id='j28C7'><center id='j28C7'></center></pre></bdo></b><th id='j28C7'></th></span></q></dt></tr></i><div id='j28C7'><tfoot id='j28C7'></tfoot><dl id='j28C7'><fieldset id='j28C7'></fieldset></dl></div>

                  <tfoot id='j28C7'></tfoot>

                • <small id='j28C7'></small><noframes id='j28C7'>

                      <legend id='j28C7'><style id='j28C7'><dir id='j28C7'><q id='j28C7'></q></dir></style></legend>