NPOI読み出しword 2007
//
public static string ExcuteWord()
{
StringBuilder sb = new StringBuilder();
using (FileStream stream = File.OpenRead("d:/test.docx"))
{
XWPFDocument doc = new XWPFDocument(stream);
var tables = doc.Tables;
foreach (var table in tables) //
{
foreach (var row in table.Rows) //
{
var c0 = row.GetCell(0); // 0
foreach (var para in c0.Paragraphs)
{
string text = para.ParagraphText;
//
sb.Append(text+",");
}
}
}
return sb.ToString();
}
}
//
public static string ExcuteWordText()
{
StringBuilder sb = new StringBuilder();
using (FileStream stream = File.OpenRead("d:/test.docx"))
{
XWPFDocument doc = new XWPFDocument(stream);
foreach (var para in doc.Paragraphs)
{
string text = para.ParagraphText; //
var runs = para.Runs;
string styleid = para.Style;
for (int i = 0; i < runs.Count; i++)
{
var run = runs[i];
text = run.ToString(); // run
sb.Append(text + ",");
}
}
}
return sb.ToString();
}
word 2003を読み込むには
NPOI読み出しword 2003