Excel 파일에 일부 테이블이있는 Word 문서를 변환 할 수있는 방법이 있습니까? 테이블을 변환하는 것이 매우 도움이됩니다. 그런OpenXML을 사용하여 Word docx를 Excel로 변환
뭔가 : XML-태그
- 열기 Word 문서
- Excel에서 테이블
- 삽입 XML-태그를 파일 만들기 Word에서 새 Excel 파일로
의미는입니다.
app.Visible = false;
workbooks = app.Workbooks;
workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);
sheets = workbook.Worksheets;
worksheet = (_Worksheet)sheets.get_Item(1);
excel(row, column, "value");
workbook.Saved = true;
workbook.SaveAs(output_file);
app.UserControl = false;
app.Quit();
: 엑셀로
using System;
using Independentsoft.Office;
using Independentsoft.Office.Word;
using Independentsoft.Office.Word.Tables;
namespace Sample
{
class Program
{
static void Main(string[] args)
{
WordDocument doc = new WordDocument("c:\\test.docx");
Table[] tables = doc.GetTables();
foreach (Table table in tables)
{
//read data
}
}
}
}
그리고 그것들을 작성하는 각 셀에 대해이 작업을 수행 할 파일 :
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
}
불행히도 OpenXML과 비슷한 기능이 필요합니다. –