如何在导出到word文档时添加页眉和页脚 [英] How to add header and footer when export to word document

查看:152
本文介绍了如何在导出到word文档时添加页眉和页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

如何使用asp.net和C#将 gridview 导出到word文档时添加页眉和页脚。



谢谢





编辑/



http://img.prntscr.com/img?url=http:// i.imgur.com/rPWToFj.png [ ^ ]

解决方案





您可以将gridview转换为word,pdf等。



参考:

1)在ASP.Net中将多个GridView导出到Word文档

2 ) [ASP.NET编程]

将GridView导出到Word使用Asp.net C#


尝试这些论坛链接 -

如何在将ASPview导出到Excel中的Excel表格时将标题添加到Excel中[ ^ ]

将gridview导出为带有标题和夏日的优秀 [ ^ ]

在ASP.Net中将带有计算器的GridView导出到Excel中的Excel << [a href =http://aspforums.net/Threads/193040/Export-GridView-with-Calculation-in-Footer-到EXC el-in-ASPNet /target =_ blanktitle =New Window> ^ ]


这假设您只是将HTML作为内容类型发送出去MS-字。在HTML文档中添加以下内容:



 <  < span class =code-leadattribute> div     style   ='  mso-element:header'    id   =   h1  >  
< p class = MsoHeader style =' border:none; mso-border-bottom-alt :solid windowtext .75pt; padding:0in; mso-padding-alt:0in 0in 1.0pt 0in' >
< o:p > 某些页眉页脚文字< / o:p >
< / p >
<! - 一些分页和日期内容 - >
< font 尺寸 =' 2' > Page
< span 样式 =' mso-field-code:PAGE' >
< span style =' mso-no-proof:是' > 1 < / span >
< span class =code-keyword>< / span > of
< span style =' mso-f ield-code:NUMPAGES' > < / span >
< span style =' mso-tab-count:9' >
< span style =' mso-field-code:DATE \\\ @ \ 0022d -MMM-yyyy \ 0022' > < / span >
< / font >
< / div >

< div 样式 =' mso-element:footer' id = f1 >
< p class = MsoFooter style =' border:none; mso-border-bottom-alt:solid windowtext .75pt; padding:0in; mso-padding-alt:0in 0 in 1.0pt 0in' >
< o:p > 一些页脚文字< / o:p > & nbsp;
< ; / p >
< font size =' 2' > 页面
< span 样式 =' mso-field-code:PAGE' >
< span style =' mso-no-proof:是' > 1 < span class =code-keyword>< / span >
< / span >
< span < span class =code-attribute> style =' mso -field-code:NUMPAGES' > < / span >
< span style = ' mso-field-code:DATE \\\ @ \ 0022d-MMM-yyyy \ 0022' > < / span >
< / font >
< / div >







定义标题和页脚区域。现在,我还有一个问题需要解决,那就是页眉和页脚信息也会出现在文档本身中。希望您可以将此作为最终解决方案的起点。


hello,
How to add header and footer when export gridview to word document using asp.net and C#.

thanks


Edit /

http://img.prntscr.com/img?url=http://i.imgur.com/rPWToFj.png[^]

解决方案

Hi,

You can convert gridview to word,pdf,etc.

Ref :
1) Export Multiple GridViews to Word Document in ASP.Net
2) [ASP.NET Programming]
Export GridView to Word Using Asp.net C#


Try these forum links -
How to add header to excel on exporting Gridview to excel sheet in ASP.Net[^]
Export gridview to excel with heading and summery[^]
Export GridView with Calculation in Footer to Excel in ASP.Net[^]


This assumes you are simply taking HTML and sending it out as content type ms-word. Add something like this to your HTML document:

<div style='mso-element:header' id=h1>
    <p class=MsoHeader style='border:none;mso-border-bottom-alt:solid windowtext .75pt;padding:0in;mso-padding-alt:0in 0in 1.0pt 0in'>
        <o:p>Some Header  Footer Text</o:p>
    </p>
    <!-- Some paging and date stuff -->
    <font size='2'>Page
        <span style='mso-field-code: PAGE '>
            <span style='mso-no-proof:yes'>1</span>
        </span> of
        <span style='mso-field-code: NUMPAGES '></span>
        <span style='mso-tab-count: 9'>
            <span style='mso-field-code:" DATE \\\@ \0022d-MMM-yyyy\0022 "'></span>
    </font>
</div>

<div style='mso-element:footer' id=f1>
    <p class=MsoFooter style='border:none;mso-border-bottom-alt:solid windowtext .75pt;padding:0in;mso-padding-alt:0in 0in 1.0pt 0in'>
        <o:p>Some Footer Text</o:p>&nbsp;
    </p>
    <font size='2'>Page
        <span style='mso-field-code: PAGE '>
            <span style='mso-no-proof:yes'>1</span>
        </span> of
        <span style='mso-field-code: NUMPAGES '></span>
        <span style='mso-field-code:" DATE \\\@ \0022d-MMM-yyyy\0022 "'></span>
    </font>
</div>




It defines the header and footer areas. Now, there is one problem with this that I have yet to solve, and that is the header and footer information will also appear in the document itself. Hopefully you can use this as a starting point for a final solution.


这篇关于如何在导出到word文档时添加页眉和页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆