如何通过C#编程只将表格内容导出到excel文件中?我目前正在使用PDFNET SDK从PDF中提取所有内容,但无法将表格作为表格结构读取
发布于 2011-08-03 19:40:27
我知道这个产品没有使用SDK,但我使用的是单机版产品。它将PDF的内容读取到电子表格中(许多导出选项)。
该产品是Nuance http://australia.nuance.com/for-business/by-product/omnipage/index.htm的OmniPage。
有一个免费评估的SDK。
发布于 2017-07-05 16:48:24
使用bytescount PDF Extractor SDK,我们可以提取整个页面,如下所示。
CSVExtractor extractor = new CSVExtractor();
extractor.RegistrationName = "demo";
extractor.RegistrationKey = "demo";
TableDetector tdetector = new TableDetector();
tdetector.RegistrationKey = "demo";
tdetector.RegistrationName = "demo";
// Load the document
extractor.LoadDocumentFromFile("C:\\sample.pdf");
tdetector.LoadDocumentFromFile("C:\\sample.pdf");
int pageCount = tdetector.GetPageCount();
for (int i = 1; i <= pageCount; i++)
{
int j = 1;
do
{
extractor.SetExtractionArea(tdetector.GetPageRect_Left(i),
tdetector.GetPageRect_Top(i),
tdetector.GetPageRect_Width(i),
tdetector.GetPageRect_Height(i)
);
// and finally save the table into CSV file
extractor.SavePageCSVToFile(i, "C:\\page-" + i + "-table-" + j + ".csv");
j++;
} while (tdetector.FindNextTable()); // search next table
}
因为这是一个老帖子,希望它能帮助其他人。
发布于 2017-11-02 11:43:51
上面的答案(John)有效,它真的很有用。
但是我使用bytescount PDF Extrator SDK工具,而不是使用代码。
顺便说一下,该工具将在一个excel文件中生成大量的工作表。
您可以在excel中使用下面的代码将其生成为一个工作表。
Sub ConvertAsOne()
Application.ScreenUpdating = False
For j = 1 To Sheets.Count
If Sheets(j).Name <> ActiveSheet.Name Then
X = Range("A65536").End(xlUp).Row + 1
Sheets(j).UsedRange.Copy Cells(X, 1)
End If
Next
Range("B1").Select
Application.ScreenUpdating = True
MsgBox "succeed!", vbInformation, "note"
End Sub
https://stackoverflow.com/questions/6925477
复制相似问题