Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Read Excel file properties.

Read Excel file properties.

Scheduled Pinned Locked Moved C#
csharpasp-netdotnettutorial
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jdkulkarni
    wrote on last edited by
    #1

    Dear All, Does anybody know how to read properties of an EXCEL file from C# application. I want to see those properties when I right click on a file and select properties.:^) Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET

    J 1 Reply Last reply
    0
    • J jdkulkarni

      Dear All, Does anybody know how to read properties of an EXCEL file from C# application. I want to see those properties when I right click on a file and select properties.:^) Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET

      J Offline
      J Offline
      jdkulkarni
      wrote on last edited by
      #2

      Guys, It's done. Dim objwb As Excel.Workbook Dim objapp As Excel.Application Dim result As Object Dim val As String Dim name As String Dim count As Integer Dim i As Integer objapp = New Excel.Application objapp.Visible = True objwb = objapp.Workbooks.Open("c:\Test.xls") 'Get properties count ' count = Int32.Parse(objwb.BuiltinDocumentProperties.GetType().InvokeMember("Count", BindingFlags.GetProperty, Nothing, objwb.BuiltinDocumentProperties, New Object() {}).ToString) count = Int32.Parse(objwb.CustomDocumentProperties.GetType().InvokeMember("Count", BindingFlags.GetProperty, Nothing, objwb.CustomDocumentProperties, New Object() {}).ToString) For i = 1 To count '(Count property is not zero-based index) 'Get Document Property at specified index result = objwb.CustomDocumentProperties.GetType().InvokeMember("Item", BindingFlags.GetProperty, Nothing, objwb.CustomDocumentProperties, New Object() {i}) 'Get Property Name name = result.GetType().InvokeMember("Name", BindingFlags.GetProperty, Nothing, result, New Object() {}).ToString Try 'Get value for Property (some properties will throw an exception if you try to access their property) val = result.GetType().InvokeMember("", BindingFlags.GetProperty, Nothing, result, New Object() {}).ToString Catch ex As Exception val = "None" End Try 'Show Property name and Value MsgBox(name.ToString & ": " & val.ToString) :-D Jayant D. Kulkarni Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups