asp.net(C#)读取word 文档的方法
第一种方法
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "Application/msword";
string s=Server.MapPath("C#语言参考.doc");
Response.WriteFile("C#语言参考.doc");
Response.Write(s);
Response.Flush();
Response.Close();
第二种方法
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "Application/msword";
string strFilePath="";
strFilePath =Server.MapPath("C#语言参考.doc");
FileStream fs = new FileStream(strFilePath,FileMode.OpenOrCreate,FileAccess.Read);
Response.WriteFile(strFilePath,,fs.Length);
fs.Close();
第三种方法
string path=Server.MapPath("C#语言参考.doc"); FileInfo file=new FileInfo(path);
FileStream myfileStream=new FileStream(path,FileMode.Open,FileAccess.Read);
byte[] filedata=new Byte[file.Length];
myfileStream.Read(filedata,,(int)(file.Length));
myfileStream.Close();
Response.Clear();
Response.ContentType="application/msword";
Response.AddHeader("Content-Disposition","attachment;filename=文件名.doc");
Response.Flush();
Response.BinaryWrite(filedata);
Response.End();
asp.net(C#)读取word 文档的方法的更多相关文章
- asp.net 读取word 文档的方法
资料一:适合读取并显示(简单而明了) 第一种方法: Response.ClearContent(); Response.ClearHeaders(); Response.ContentTyp ...
- C#读取Word文档内容代码
首先要添加引用com组件:然后引用: using Word = Microsoft.Office.Interop.Word; 获取内容: /// /// 读取 word文档 返回内容 /// //// ...
- asp.net如何实现word文档在线预览
原文:asp.net如何实现word文档在线预览 实现方式:office文档转html,再在浏览器里面在线浏览 1.首先引入com组件中office库,然后在程序集扩展中引入word的dll 2.将M ...
- Python读取word文档(python-docx包)
最近想统计word文档中的一些信息,人工统计的话...三天三夜吧 python 不愧是万能语言,发现有一个包叫做 docx,非常好用,具体查看官方文档:https://python-docx.read ...
- C# 设置、删除、读取Word文档背景——基于Spire.Cloud.Word
Spire.Cloud.Word.Sdk提供了接口SetBackgroudColor().SetBackgroudImage().DeleteBackground().GetBackgroudColo ...
- 利用POI工具读取word文档并将数据存储到sqlserver数据库中
今天实现了利用POI工具读取word文档,并将数据存储到sql数据库中,代码如下: package word; import java.io.File; import java.io.FileInpu ...
- Python读取word文档内容
1,利用python读取纯文字的word文档,读取段落和段落里的文字. 先读取段落,代码如下: 1 ''' 2 #利用python读取word文档,先读取段落 3 ''' 4 #导入所需库 5 fro ...
- java中读取word文档里的内容
package com.cn.peitest.excel.word; import java.io.FileInputStream; import java.io.FileOutputStream; ...
- [转载]linux上用PHP读取WORD文档
在linux上用PHP读取WORD文档,其实是使用了 antiword程序把word文档转化为txt文档. 再使用php执行系统命令调用而已. 具体操作如下: 1.安装antiword 官方站:htt ...
随机推荐
- Java中main函数参数String args[] 和 String[] args 区别
其实没什么区别的:当初我也是这样的疑问,呵呵:非要说区别就看下面:执行效果上没有不同, 但在语法意义上略有不同. 比如, String与String[], 前者叫字符串类型而后者叫字符串数组类型. S ...
- c语言调试接口
http://blog.chinaunix.net/uid-10106787-id-2985587.html 在C语言程序设计中,常会出现各种各样的bug:段错误.参数异常等等.我们需要尽快定位错误, ...
- ubuntu 下dbus的环境搭建和使用
从https://launchpad.net/ubuntu/+source/dbus/1.10.6-1ubuntu2下载需要的dbus包,然后解压,./configure make && ...
- [css]兼容性
div +input 输入框 , 在微信中 有问题 块级元素 行内元素
- PIGCMS提示“你的程序为盗版,非法授权,请联系QQ7530782或者8441010”的修复方法
最近群里又有人发出来微信平台盗版源码这个问题求解决,其实我本人是一直支持正版的,大家有条件的还是购买正好为好,既然有人问我就顺便解决了下,其实很简单,再换个接口就好了,查看了一下是在\PigCms\L ...
- 在线压缩zip
<?php //验证密码 $password = "test"; ?> <html> <head> <meta http-equiv=&q ...
- return的用法
1.一般的就是用在有返回值的方法中,用来返回方法指定类型的值,同时结束方法执行: 2.可以用在返回值为void的方法中,用来终止方法运行:
- UML 小结(1)- 整体阐述
前言: UML( Unified Modeling Language) 又称统一建模语言或标准建模语言,是始于1997年一个OMG标准,它是一个支持模型化和软件系统开发的图形 ...
- cocos2dx中常见的类及类继承关系
场景:CCScene,继承自CCNode,几乎完全等于CCNode类 CCNode继承自CCObject,CCObject是真正意义上的父类,CCObject又继承自CCCopying类,CCCopy ...
- cocos2dx中的菜单项CCMenuItem及其五个子类的使用
/*CCMenuItem是一个虚基类,因此必须实现它的五个子类之一,再把子类对象赋给父类指针,相当于多态*/ CCMenuItem *fontItem = CCMenuItemFont::create ...