html转word java_word转excel排版不变

html转word java_word转excel排版不变页面:无标题页页面后置文件:usingSystem;usingSystem.Collections;usingSystem.Configuration;usingSystem.Data;usingSystem.Linq;usingSystem.Web;usingSystem.

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

页面:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    </div>
    </form>
</body>
</html>

页面后置文件:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Microsoft.Office.Interop.Word;    //注意要先引用

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public void educeDoc(string FileName)
    {
        //清除反冲区的内容
        Response.Clear();
        //设置输出流的http字符集
        Response.Charset = "gb2312";
        //将一个HTTP头添加到输出流
        Response.AddHeader("content-disposition", "attachment;filename=" + FileName);
        //设置输出的HTTP MIME类型
        Response.ContentType = "application/vnd.doc";

        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        sb.Append(@"<table border='1' >
<tr>
<td>123</td>
<td>456</td></tr>
<tr>
<td>678</td>
<td>890</td></tr>
<tr>
<td>222</td>
<td><img src='http://www.iteye.com/images/user-logo.gif?1324994303' alt='ourteam的博客'></td></tr>
</table>");

        //把字符数组写入HTTP响应输出流
        Response.Write(sb.ToString());
        //发送完,关闭
        Response.End();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        educeDoc("1.doc");//最终输出的文件名就是 "1.doc"
    }
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/184397.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • java128陷阱

    java128陷阱public static void main(String[] args){ Integer a=128; Integer b=128; System.out.print(a==b);//false a=127; b=127; System.out.print(a==b);//true}为什么对于一个Integer来说,两个Integer都为128的时候通过判断为false,127时的却是true呢?其实这一切都是因为Java中的装箱

    2022年8月8日
    5
  • AS2 笔记 1——attachMovie 添加库影片

    AS2 笔记 1——attachMovie 添加库影片this["container"].attachMovie("useLoad","useLoadMc",this.getNextHigh

    2022年7月2日
    30
  • MATLAB中的norm函数

    MATLAB中的norm函数MATLAB 中的 norm 函数

    2025年7月24日
    3
  • 解决跨域问题 has been blocked by CORS policy: No ‘Access-Control-Allow-Origin‘ header is present[通俗易懂]

    解决跨域问题 has been blocked by CORS policy: No ‘Access-Control-Allow-Origin‘ header is present[通俗易懂]说一下做项目时需要用到html2canvas做项目截图踩到的跨域坑。项目需要拉取用户的头像,而linkedin和微信的头像存放于cdn中,这边涉及到的跨域问题。坑1:由于跨域,画布被污染,不能调用toBlob(),toDataURL()或getImageData()方法,调用它们会抛出安全错误。按网上说的做,配置useCORS:true,…

    2022年8月24日
    51
  • leetcode-1074. 元素和为目标值的子矩阵数量(前缀和+hash)

    leetcode-1074. 元素和为目标值的子矩阵数量(前缀和+hash)给出矩阵 matrix 和目标值 target,返回元素总和等于目标值的非空子矩阵的数量。子矩阵 x1, y1, x2, y2 是满足 x1 <= x <= x2 且 y1 <= y <= y2 的所有单元 matrix[x][y] 的集合。如果 (x1, y1, x2, y2) 和 (x1’, y1’, x2’, y2’) 两个子矩阵中部分坐标不同(如:x1 != x1’),那么这两个子矩阵也不同。示例 1:输入:matrix = [[0,1,0],[1,1,1],

    2022年8月11日
    3
  • html 鼠标形状箭头,CSS各种鼠标样式介绍

    html 鼠标形状箭头,CSS各种鼠标样式介绍大家否曾注意到有些网站的鼠标不是规则的斜向上箭头的形状,而是十字形,或者是向左的箭头,或者是个问号等等。当你想在网页的不同位置让鼠标显示不同形状,以体现不同的功能区;当你想让你的网站体现与众不同的风格时,考虑一下在鼠标样式上下功夫吧。其实鼠标样式的用途还是极为广泛的,那么怎样才能实现鼠标的不同样式呢?这就要用到css层叠样式表中的cursor属性了。cursor的属性:pointer:手型c…

    2022年5月27日
    194

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号