kuba
kuba

Reputation: 1009

How to use Excel file from visual studio project resource

I add an excel file to my project resource, and I would like to open it, but method woorkobook.open() take only path string as parameter :-(

What is the proper way to open and use those excel files from resource?

Upvotes: 0

Views: 4084

Answers (2)

AMissico
AMissico

Reputation: 21684

Office applications are before the time of .NET Streams. The applications only work with physical files. You must copy the resource to a physical file or use a third-party component.

        Dim sPath As String = My.Computer.FileSystem.GetTempFileName
        My.Computer.FileSystem.WriteAllBytes(sPath, My.Resources.us, False)

Upvotes: 1

pierroz
pierroz

Reputation: 7870

in VS, if you set the property "Copy to Output Directory" to "Copy always", on the excel file you've added to your project, you can then directly use the name of your file as the value of the path.

Upvotes: 1

Related Questions