Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Everyone

I am a VB.net beginner .I have a pdf file with tabular data.How can I code that the PDF tabular data is Exported into an Excel Sheet in VB.Net.


Thanks
Posted

As a beginner, you should learn to program before playing with stuff like this.

To parse a PDF you need a third party library, most of which cost money. To open stuff in Excel, the easiest way is to create a CSV, a text file where each line is a row, with commas between values.
 
Share this answer
 
Comments
Geo Jackson 18-Jul-12 4:06am    
But After Converting into Excel file i'm moving the data from Excel to SQL ,I have done that part. kindly give a suggestion to export to Excel
Christian Graus 18-Jul-12 4:18am    
I've told you how to export in to Excel, Excel can open a CSV. If you're moving data to SQL, why do you need Excel in the middle ?
Geo Jackson 18-Jul-12 4:58am    
Excel File is processed by our concern for their internal purpose
Christian Graus 18-Jul-12 5:00am    
OK, so create a CSV and they can open it in Excel. Or buy a library or use the Microsoft tools to create an Excel file. I'm just trying to give you a basic idea of how to do it easily because you clearly have no clue.
Geo Jackson 18-Jul-12 5:02am    
Thanks
VB.Net把excel导出PDF文件的实例

Imports Microsoft.VisualStudio.Tools.Applications.Runtime
Imports Excel = Microsoft.Office.Interop.Excel
Imports Office = Microsoft.Office.Core

Public Class Sheet1
Private MyShowDataMenu As Office.CommandBarButton
Private MyExportPDFMenu As Office.CommandBarButton
Private MyExportXPSMenu As Office.CommandBarButton
Private Sub Sheet1_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
AddMenuBar()
End Sub
Private Sub Sheet1_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
End Sub
Private Sub AddMenuBar()
Try
Dim missing = System.Reflection.Missing.Value
Dim MyCommandBarPopup As Office.CommandBarPopup = Nothing
Dim MyCommandBarMenu As Office.CommandBar = CType( _
Application.CommandBars.ActiveMenuBar, Office.CommandBar)
Dim MyControlsCount As Integer = MyCommandBarMenu.Controls.Count
MyCommandBarPopup = CType(MyCommandBarMenu.Controls.Add( _
Office.MsoControlType.msoControlPopup, missing, missing, _
MyControlsCount, True), Office.CommandBarPopup)
If (MyCommandBarPopup IsNot Nothing) Then
MyCommandBarPopup.Caption = "数据导入导出"
MyShowDataMenu = CType(MyCommandBarPopup.Controls.Add( _
Office.MsoControlType.msoControlButton, missing, _
missing, missing, True), Office.CommandBarButton)
MyShowDataMenu.Caption = "显示客户信息"
MyShowDataMenu.TooltipText = "显示Northwind数据库""客户""数据表的信息"
MyShowDataMenu.FaceId = 65
AddHandler MyShowDataMenu.Click, AddressOf MyShowDataMenuCommand_Click
MyExportPDFMenu = CType(MyCommandBarPopup.Controls.Add( _
Office.MsoControlType.msoControlButton, missing, missing, _
missing, True), Office.CommandBarButton)
MyExportPDFMenu.Caption = "导出PDF文件"
MyExportPDFMenu.TooltipText = "将当前工作表中显示的内容导出为PDF文件"
MyExportPDFMenu.FaceId = 66
AddHandler MyExportPDFMenu.Click, AddressOf MyExportPDFMenuCommand_Click
MyExportXPSMenu = CType(MyCommandBarPopup.Controls.Add( _
Office.MsoControlType.msoControlButton, missing, missing, _
missing, True), Office.CommandBarButton)
MyExportXPSMenu.Caption = "导出XPS文件"
MyExportXPSMenu.TooltipText = "将当前工作表中显示的内容导出为XPS文件"
MyExportXPSMenu.FaceId = 67
AddHandler MyExportXPSMenu.Click, AddressOf MyExportXPSMenuCommand_Click
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "乐博网信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
'显示客户信息
Private Sub MyShowDataMenuCommand_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Dim MySQL As String = "Select 客户ID,公司名称,联系人姓名,地址 From 客户"
Dim MyPath As String = "G:\Northwind.mdb"
Dim missing = System.Reflection.Missing.Value
Dim MyRange As Excel.Range = Globals.Sheet1.Range("A3", missing)
Dim MyQueryTables As Excel.QueryTables = Globals.Sheet1.QueryTables
Dim MyQueryTable As Excel.QueryTable = MyQueryTables.Add( _
"OLEDB;Provider= Microsoft.Jet.OLEDB.4.0;Data Source=" + _
MyPath + ";", MyRange, MySQL)
MyQueryTable.RefreshStyle = Excel.XlCellInsertionMode.xlInsertEntireRows
MyQueryTable.Refresh(False)
End Sub
'导出PDF文件
Private Sub MyExportPDFMenuCommand_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Dim MyFileName As String = "G:\MyExcelPDF.pdf"
Dim MyDlg As New SaveFileDialog()
MyDlg.AddExtension = True
MyDlg.DefaultExt = "pdf"
If (MyDlg.ShowDialog() = DialogResult.OK) Then
MyFileName = MyDlg.FileName
End If
Dim missing = System.Reflection.Missing.Value
Me.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF, _
MyFileName, Excel.XlFixedFormatQuality.xlQualityStandard, _
True, False, missing, missing, True, missing)
End Sub

End Class
 
Share this answer
 
Comments
Geo Jackson 18-Jul-12 4:58am    
Do I have to add any References
Geo Jackson 18-Jul-12 5:09am    
I think this is doing Excel to PDF , Am i right

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900