惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

W
WeLiveSecurity
The GitHub Blog
The GitHub Blog
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
The Register - Security
The Register - Security
Stack Overflow Blog
Stack Overflow Blog
博客园 - 三生石上(FineUI控件)
T
Threat Research - Cisco Blogs
S
SegmentFault 最新的问题
V2EX - 技术
V2EX - 技术
Hacker News: Ask HN
Hacker News: Ask HN
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
P
Proofpoint News Feed
J
Java Code Geeks
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
AI
AI
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
B
Blog
N
News and Events Feed by Topic
N
News | PayPal Newsroom
Google DeepMind News
Google DeepMind News
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
WordPress大学
WordPress大学
C
Cybersecurity and Infrastructure Security Agency CISA
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 【当耐特】
U
Unit 42
腾讯CDC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
H
Help Net Security
Recent Announcements
Recent Announcements
P
Privacy & Cybersecurity Law Blog
IT之家
IT之家
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Archives - TechRepublic
Security Archives - TechRepublic
L
LINUX DO - 热门话题
Martin Fowler
Martin Fowler
MongoDB | Blog
MongoDB | Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
H
Heimdal Security Blog
博客园 - 聂微东
S
Securelist
大猫的无限游戏
大猫的无限游戏
Cloudbric
Cloudbric
Cisco Talos Blog
Cisco Talos Blog

博客园 - 青青木

在三层交换机上开专线IP的方法 [转]静态框架导航,左侧折叠树的样式,类似于treeview 在ASP.NET中使用FCKEditor的简单配置方法 Matlab与Access数据库的连接 [转]用matlab做聚类分析 Word 2003特殊符号录入与编辑(转) C++内存分配的五种的区别(转) C#中正则表达式的完全匹配 插入SQL语句后,返回刚插入记录的ID asp.net定义用户控件时,属性持久化和如何动态加载的问题 命名空间“Microsoft office”中不存在类型或命名空间名称“Interop” GridView相应模板列中的LinkButton按钮的事件 visual studio 2005 和 sql server 2005 安装时需要注意的事项 使用ConfigurationManager需要在.net引用中添加System.Configuration引用 还原数据库后,用户名出错,不能修改用户属性 DataView设置datasource后,需要databind() asp.net中重命名网页的一种方法 C++语言中的虚函数 vc中出现“没有找到mspdb60.dll文件”时 ,解决方法
ASP.net2.0把word、excel转换成Html(转)
青青木 · 2009-09-29 · via 博客园 - 青青木

 

//网站 ---添加引用--com--Microsoft Excel 9.0 object Library .// Microsoft Word 9.0 object Library

using System.Reflection;
using Excel;
using System.Diagnostics;
using Microsoft.Office;

public partial class tel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//word
Response.Write(Get_Html("New.doc"));
//excel
ExcelConvertToHtml("E:\\12345.xls","E:\\aaa.html");
}


protected void ExcelConvertToHtml(string xlsPath, string htmlPath)
{
try
{
Excel.Application app
= new Excel.Application();
app.Visible
= false;
Object o
= Missing.Value;

/// _Workbook xls=app.Workbooks.Open(xlsPath,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o);

_Workbook xls
= app.Workbooks.Open(xlsPath, o, o, o, o, o, o, o, o, o, o, o, o);
object fileName = htmlPath;
object format = Excel.XlFileFormat.xlHtml;//Html

// xls.SaveAs(ref fileName,ref format,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o,ref o);
xls.SaveAs(fileName, format, o, o, o, o, XlSaveAsAccessMode.xlExclusive, o, o, o, o);
//xls.SaveAs(
object t = true;
app.Quit();

Process[] myProcesses
= Process.GetProcessesByName("EXCEL");
foreach (Process myProcess in myProcesses)
{
myProcess.Kill();
}

}

catch (Exception ex)
{
System.Console.Write(ex.Message);
// MessageBox.Show(ex.Message);
}

}

private string Get_Html(string FileName)
{

Word.ApplicationClass word
= new Word.ApplicationClass();
Type wordType
= word.GetType();
Word.Documents docs
= word.Documents;

// 打开文件
Type docsType = docs.GetType();
// RAID.doc
// string newFileNamePath = this.Server.MapPath(mydata.Config.SysUploadPath + "/" + FileName);
string newFileNamePath = this.Server.MapPath("download/" + FileName);
Word.Document doc
= (Word.Document)docsType.InvokeMember

(
"Open", System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[] { newFileNamePath, true,

true }
);

// 转换格式,另存为
Type docType = doc.GetType();
object saveFileName = newFileNamePath.Replace(".doc", ".htm");
//下面是Microsoft Word 9 Object Library的写法,如果是10,可能写成:
/*
docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod,
null, doc, new object[]{saveFileName, Word.WdSaveFormat.wdFormatFilteredHTML});
*/

///其它格式:
///wdFormatHTML
///wdFormatDocument
///wdFormatDOSText
///wdFormatDOSTextLineBreaks
///wdFormatEncodedText
///wdFormatRTF
///wdFormatTemplate
///wdFormatText
///wdFormatTextLineBreaks
///wdFormatUnicodeText

docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod, null, doc, new object[] { saveFileName, Word.WdSaveFormat.wdFormatHTML });

// 退出 Word
wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, word, null);

string newFileName = FileName.Replace(".doc", ".htm");
return (newFileName);
}


}