将Word文档转换为Excel,可以采用以下几种方法,确保格式尽可能保持不变:
一些网页编辑人员在更新网站内容时,通常会先将内容保存为PDF文件,然后在发布时将PDF转换为HTML格式。
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test1.aspx.cs" Inherits="WebApplication1.Excel1.tohtml.test1" %><!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>EXCEL转换成html文件</title></head><body> <form id="form1" runat="server"> <div> </div> <asp:Button ID="Button1" runat="server" Text="开始转换" onclick="Button1_Click" /> </form></body></html>后台:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Reflection;using Microsoft.Office.Interop.Excel;using System.Diagnostics;using WebApplication1.common;namespace WebApplication1.Excel1.tohtml{ public partial class test1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { excel_to.ExcelConvertToHtml(Server.MapPath("../data/test1.xls"), Server.MapPath("../data/test2.html")); } }}
PDF是在传输过程中常用的文档格式,而HTML是浏览网页时比较常见的格式,这两种看似搭不着边相差甚远的格式,居然也可以进行转换。