请问高手,如何从word文档中获取数据? 我在网上下载了一个考试的题库,不过是word文档,数据量大 我想存到数据库中请问如何才能获取到word文档中的数据? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 数据 ? Word文档?一般是读取excel中的数据 放到数据库? 这是读取EXCEL的代码,将EXCLE数据读到DATATABLE中,其它的你就自己写吧 string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + file + ";" + "Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'"; OleDbDataAdapter ExcelDA = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn); DataSet ExcelDs = new DataSet(); try { ExcelDA.Fill(ExcelDs, "ExcelInfo"); DataTable dt = ExcelDs.Tables[0]; return dt; } catch (Exception err) { Response.Write(err.ToString()); } return null; 这个读写WORD文档///#region 打开Word文档,并且返回对象wDoc,wDoc /// /// 打开Word文档,并且返回对象wDoc,wDoc /// /// 完整Word文件路径+名称 /// 返回的Word.Document wDoc对象 /// 返回的Word.Application对象 public static void CreateWordDocument(string FileName,ref Word.Document wDoc,ref Word.Application WApp) { if(FileName == "") return; Word.Document thisDocument = null; Word.FormFields formFields = null; Word.Application thisApplication = new Word.ApplicationClass(); thisApplication.Visible = true; thisApplication.Caption = ""; thisApplication.Options.CheckSpellingAsYouType = false; thisApplication.Options.CheckGrammarAsYouType = false; Object filename = FileName; Object ConfirmConversions = false; Object ReadOnly = true; Object AddToRecentFiles = false; Object PasswordDocument = System.Type.Missing; Object PasswordTemplate = System.Type.Missing; Object Revert = System.Type.Missing; Object WritePasswordDocument = System.Type.Missing; Object WritePasswordTemplate = System.Type.Missing; Object Format = System.Type.Missing; Object Encoding = System.Type.Missing; Object Visible = System.Type.Missing; Object OpenAndRepair = System.Type.Missing; Object DocumentDirection = System.Type.Missing; Object NoEncodingDialog = System.Type.Missing; Object XMLTransform = System.Type.Missing; try { Word.Document wordDoc = thisApplication.Documents.Open(ref filename, ref ConfirmConversions, ref ReadOnly, ref AddToRecentFiles, ref PasswordDocument, ref PasswordTemplate, ref Revert,ref WritePasswordDocument, ref WritePasswordTemplate, ref Format, ref Encoding, ref Visible, ref OpenAndRepair, ref DocumentDirection, ref NoEncodingDialog, ref XMLTransform ); thisDocument = wordDoc; wDoc = wordDoc; WApp = thisApplication; formFields = wordDoc.FormFields; } catch(Exception ex) { MessageBox.Show(ex.Message); } } #endregion this one is Excel,not for word.wait for the Word... 将WORD文档另存为RTF格式,然后放到数据库中,展现时使用RichTextBox控件 Word 是哪儿个命名空间的? 请问如何将32位图像转换成8位图像 大家看看我这段代码问题在哪里? string 中怎样编号子串 使用FileSystemWatcher 报错 - 文件“D:\Temp\test.txt”正由另一进程使用,因此该进程无法访问该文件。 有没有办法实现简单类型的浅拷贝?没人知道吗?呜呜呜~~~~ 终于知道C#的动态类型有什么用了。 如何通过窗口句柄来获得或创建 Form 对象!? POST方法的参数怎么写? 初学 C# 请大家给一些学习建议并介绍几本快入门的书籍! 有谁知道.iso文件怎样才能刻成盘。 C++ 如何转换到 C#? C#中定义常量
一般是读取excel中的数据 放到数据库? 这是读取EXCEL的代码,将EXCLE数据读到DATATABLE中,其它的你就自己写吧
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + file + ";" +
"Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'";
OleDbDataAdapter ExcelDA = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", strConn);
DataSet ExcelDs = new DataSet();
try
{
ExcelDA.Fill(ExcelDs, "ExcelInfo"); DataTable dt = ExcelDs.Tables[0]; return dt; }
catch (Exception err)
{
Response.Write(err.ToString());
} return null;
///#region 打开Word文档,并且返回对象wDoc,wDoc
///
/// 打开Word文档,并且返回对象wDoc,wDoc
///
/// 完整Word文件路径+名称
/// 返回的Word.Document wDoc对象
/// 返回的Word.Application对象
public static void CreateWordDocument(string FileName,ref Word.Document wDoc,ref Word.Application WApp)
{
if(FileName == "") return;
Word.Document thisDocument = null;
Word.FormFields formFields = null;
Word.Application thisApplication = new Word.ApplicationClass();
thisApplication.Visible = true;
thisApplication.Caption = "";
thisApplication.Options.CheckSpellingAsYouType = false;
thisApplication.Options.CheckGrammarAsYouType = false; Object filename = FileName;
Object ConfirmConversions = false;
Object ReadOnly = true;
Object AddToRecentFiles = false; Object PasswordDocument = System.Type.Missing;
Object PasswordTemplate = System.Type.Missing;
Object Revert = System.Type.Missing;
Object WritePasswordDocument = System.Type.Missing;
Object WritePasswordTemplate = System.Type.Missing;
Object Format = System.Type.Missing;
Object Encoding = System.Type.Missing;
Object Visible = System.Type.Missing;
Object OpenAndRepair = System.Type.Missing;
Object DocumentDirection = System.Type.Missing;
Object NoEncodingDialog = System.Type.Missing;
Object XMLTransform = System.Type.Missing; try
{
Word.Document wordDoc =
thisApplication.Documents.Open(ref filename, ref ConfirmConversions,
ref ReadOnly, ref AddToRecentFiles, ref PasswordDocument, ref PasswordTemplate,
ref Revert,ref WritePasswordDocument, ref WritePasswordTemplate, ref Format,
ref Encoding, ref Visible, ref OpenAndRepair, ref DocumentDirection,
ref NoEncodingDialog, ref XMLTransform ); thisDocument = wordDoc;
wDoc = wordDoc;
WApp = thisApplication;
formFields = wordDoc.FormFields;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
} }
#endregion
this one is Excel,not for word.
wait for the Word...