/* 這裡是讀取word到docum**
wordprocessingdocument word = null; //建立空文書並開啟
opensettings opensettings = new opensettings() ;
word = wordprocessingdocument.open(filepath, true, opensettings); //開啟word
documentformat.openxml.wordprocessing.body openxmldocumentbody = null;
openxmldocumentbody = word.maindocumentpart.document.body;
*//// ///
///
/// 當前操作的綱要節點
/// 當前操作的綱要節點
///
internal listbuildwordelement(recordanalysissubmitbody schemanode, xmlcrolayoutmodelbody crolayoutnode);}
#endregion
#region 字型大小
if (!string.isnullorwhitespace(crolayoutnode.titleformat.fontsize));}
#endregion
#region 加粗
if (crolayoutnode.titleformat.fontbold.tostring() == "true")
#endregion
#region 對其方式
justification justification1 = new justification();
switch (crolayoutnode.titleformat.paragraphalignment);}
//居中齊
case "3":;}
//右對齊
case "2":;}
//兩端
case "4":
;break;}}
#endregion
#region 縮排 需要明確
indentation indentation1 = new indentation();
//首行縮排
if (!string.isnullorempty(crolayoutnode.titleformat.paragraphfirstlineindent) &&
crolayoutnode.titleformat.paragraphfirstlineindent != "0")
//左縮排
if (!string.isnullorempty(crolayoutnode.titleformat.paragraphindentationleft) &&
crolayoutnode.titleformat.paragraphindentationleft != "0")
#endregion
#region 行間距
//端前
spacingbetweenlines spacingbetweenlines1 = new spacingbetweenlines() ;
if (!string.isnullorempty(crolayoutnode.titleformat.paragraphbefore) &&
crolayoutnode.titleformat.paragraphbefore != "0")
//端後
if (!string.isnullorempty(crolayoutnode.titleformat.paragraphafter) &&
crolayoutnode.titleformat.paragraphafter != "0")
if (!string.isnullorempty(crolayoutnode.titleformat.paragraphlinespacing) &&
crolayoutnode.titleformat.paragraphlinespacing != "0")
#endregion
}elements.add(paragraphtitle);
}#endregion
paragraph paragraphcontent = new paragraph();
#region 寫入綱要節點
#region 格式
paragraphproperties paragraphcontentproper = new paragraphproperties();
paragraphmarkrunproperties paragraphcontentproperrun = new
paragraphmarkrunproperties();
#endregion
run runcontent = new run();
runproperties runcontentproperties1 = new runproperties();
if (crolayoutnode.contentformat != null && crolayoutnode.contentformat.enable.tostring() == "true")
;kern kern1 = new kern() ;
}#endregion
#region 字型大小
if (!string.isnullorwhitespace(crolayoutnode.contentformat.fontsize))
;underline underline1 = new underline() ;
}#endregion
#region 加粗
if (crolayoutnode.contentformat.fontbold.tostring() == "true")
#endregion
#region 對其方式
justification justification1 = new justification();
switch (crolayoutnode.titleformat.paragraphalignment);}
//居中齊
case "3":;}
//右對齊
case "2":;}
//兩端
case "4":
;break;}}
#endregion
#region 縮排 需要明確
indentation indentation1 = new indentation();
//首行縮排
if (!string.isnullorempty(crolayoutnode.contentformat.paragraphfirstlineindent) &&
crolayoutnode.contentformat.paragraphfirstlineindent != "0")
//左縮排
if (!string.isnullorempty(crolayoutnode.contentformat.paragraphindentationleft) &&
crolayoutnode.contentformat.paragraphindentationleft != "0")
#endregion
#region 行間距
//端前
spacingbetweenlines spacingbetweenlines1 = new spacingbetweenlines() ;
if (!string.isnullorempty(crolayoutnode.contentformat.paragraphbefore) &&
crolayoutnode.contentformat.paragraphbefore != "0")
//端後
if (!string.isnullorempty(crolayoutnode.contentformat.paragraphafter) &&
crolayoutnode.contentformat.paragraphafter != "0")
if (!string.isnullorempty(crolayoutnode.contentformat.paragraphlinespacing) &&
crolayoutnode.contentformat.paragraphlinespacing != "0")
else
#endregion
}foreach (model.receipt_model.base.recordcontent c in schemanode.contents)
elements.add(paragraphcontent);
#endregion
return elements;
}
OpenXml讀取word內容的例項
openxml讀取word內容注意事項 1 使用openxml讀取word內容,word字尾必須是 docx 如果word字尾是 do程式設計客棧c 需要轉成 docx 後,才可以讀取 2 需要引入相關dll windowsbase.dll documentformat.openxml.dll 3 ...
WORD操作的問題
最近有個小專案主要是對文件,特別是word的操作,讀取 資料存到資料庫 想了想是用什麼開發呢?c 常用的,沒話說,也方便,可是還想用linux伺服器 centos 這個對我來說是個新東西,c apsnet 這個可以用jexus mono 沒有問題 database sqlserver是不行了,那就m...
word操作總結
提取碼 iwro 在公司工程中,有好多需求需要用到匯出word檔案,走過好多路,最早用的csdn上乙個vb寫的庫匯出word,完成當時乙個緊迫專案 後來繼續研究報表時,用了qt的com元件呼叫庫,來呼叫微軟的office元件進行報表匯出,此功能要求電腦必須裝了office,並且office com元...