テーブルがいくつかある Word 文書を Excel ファイルに変換する方法はありますか? テーブルを変換すると非常に便利です。
そんな感じ:
- OpenXML を使用して Word 文書を開く
- すべてのテーブルの xml-tags を検索
- xml タグをコピーする
- エクセルファイルを作成
- Wordから新しいExcelファイルにテーブルを含むxmlタグを挿入します
つまり
void OpenWordDoc(string filePath)
{
_documentWord = SpreadsheetDocument.Open(filePath, true);
}
List<string> GetAllTablesXMLTags()
{
//find and copy
}
List<string> CreateExcelFile(string filePath)
{
TemplateExcelDocument excelDocument = new TemplateExcelDocument();
_documentExcel = excelDocument.CreatePackage(filePath);
}
void InsertXmlTagsToExcelFile(string filePath)
{
CreateExcelFiles(filePath);
var xmlTable = GetAllTablesXMLTags();
// ... insert to _documentExcel
}