vba - 如何将智能 PDF 表单数据导出为没有图像的 excel 格式?
问题描述
我有大量的 PDF 表单(格式相同),我想导出到可过滤的 Excel 文件。这些表格包含贯穿始终的图像。使用 adobe 标准导出时,得到的 .csv 文件包含大量随机字符作为“图像数据”。由于我有这么多 pdf 表格,我显然不想包括这个。将文件导入excel时,由于图像数据,会生成大量的随机字符列和行
我一直在用 VBA 写一些东西来尝试排除无意义的列,但是我的代码太具体而且太慢了。我想要一种更有效的方法来做到这一点。
Sub OpenCSV()
Application.ScreenUpdating = False
Dim FilePath As String, rownumber As Integer, j As Integer
'Select The File
FilePath = Application.GetOpenFilename("Text Files (*.csv),*.csv", , "Select CSV file")
Open FilePath For Input As #1
rownumber = 0
' Loop continues until End Of File
Do Until EOF(1)
Line Input #1, LineFromFile
'Make an array from the file
LineItems = Split(LineFromFile, ",")
j = 0
For i = 0 To 314
' This If statement removes the images (only works if report is in exact same format)
If i <> 86 And i <> 87 And i <> 88 And i <> 89 Then
Cells(1, 1).Offset(rownumber, j).Value = LineItems(i)
j = j + 1
End If
Next i
rownumber = rownumber + 1
Loop
Close #1
End Sub
这运行缓慢,如果缺少表单条目等通常会导致错误。我愿意改进此代码,或者如果存在某种软件解决方案则放弃它。
解决方案
使用 VBA,您只能提取表单信息而不是图像。请参阅此处的示例:https ://github.com/pdftables/vba-pdftables-api/blob/master/pdftables.vba
推荐阅读
- flutter - setState() 在构造函数中调用:_ModalIngredientsState#60ddf(生命周期状态:已创建,无小部件,未安装)
- python - 为什么 python 发布请求返回 200 html 而 CURL 返回 303(重定向)?
- heroku - 在 Heroku 上托管 .NET Core 控制台应用程序时保持应用程序处于活动状态
- r - 如何在 R 中实现小波变换?
- matlab - 在 Matlab 中用球坐标写方程
- oauth - 首次登录后获取 google oauth 刷新令牌
- postgresql - RDS升级postgres 13.1版,不支持的DB Instance Class
- python - Python中的异常处理是如何实现的?
- r - 从等于特定日期的值中减去值
- javascript - 调用多个触发器