Guide for VB.NET
Core Document Formats
Get to Start - Create, Load, Save
Additional Features

VB.NET Excel - Create, Load, and Save Excel

Guide for Creating, Loading and Saving Excel Document in VB.NET

VB.NET
Home > .NET Imaging SDK > VB.NET > How to Start with Excel
To get started with DocImage SDK for .NET, you are supposed to read VB.NET Imaging: Get Started first!

Using our VB.NET Excel Reading SDK, you can easily and quickly create, load and save Excel document through VB.NET application. Please view the following questions on creating, loading and saving Microsoft Excel document and find the answers from this detailed VB.NET guide page.
Related .net document control helps:
asp.net mvc pdf editor control: ASP.NET MVC PDF Viewer & Editor: view, annotate, redact, edit PDF document in C# ASP.NET MVC
document viewer asp.net c#: ASP.NET Document Viewer using C#: Open, View, Annotate, Redact, Convert document files in ASP.NET using C#, HTML5, JQuer...
asp.net edit pdf text control: ASP.NET PDF Text Edit Control: online edit PDF text content using C# ASP.NET
asp.net image viewer jquery: ASP.NET Image Viewer Control(MVC & WebForms): view, annotate, redact, convert image files in html, JQuery
powerpoint viewer asp.net mvc: ASP.NET PowerPoint Document Viewer Control (MVC & WebForms): view ppt, pptx files online in C# using ASP.NET
asp.net annotate pdf control: ASP.NET Annotate PDF Control: annotate, comment, markup PDF document online using ASP.NET C#
asp.net office document viewer: ASP.NET Office Word Document Viewer: view Word doc files online using C# in ASP.NET MVC web applications
  • What preparations should VB.NET developers make to create, load and save Excel document?
  • How to create Microsoft Excel document through VB.NET programming?
  • How to load Excel document from local file or stream in VB.NET application?
  • How to use VB.NET sample code to save Excel document to local file or memory stream?
Besides VB.NET guide for Excel creating, loading, and saving, we also provide C#.NET developers with How to Start C#.NET Excel Creating, Loading & Saving.
Preparations to Be Made

.NET Environment Preparation

If you want to user our VB.NET Excel Reading SDK to create, load and save standard Excel document in VB.NET application, you may need to install .NET Framework 2.0 or greater versions and Microsoft Visual Studio 2005 or later versions.

DLLs Preparation

VB.NET developers need to download the trail version of RasterEdge Excel Reading SDK and unzip it. Then find RasterEdge.Imaging.Basic.dll and RasterEdge.Imaging.MSExcel.dll and locate the two dlls into your project references.

Excel Version Checking

Please make certain whether your Excel document is version 2007 or above. If not, you may not able to create, load and save Excel document in VB.NET project because our VB.NET Excel Reading Library only supports Excel 2007 or later versions.
Create Excel Document
VB.NET developers are free to use the following API and demo code to create blank Microsoft Excel document.

API for Creating Excel Document in VB.NET

XLSXDocument()
Simply speaking, XLSXDocument object is an abstraction of Excel document in memory. An XLSXDocument object contains all Excel documentation properties and information of all Excel worksheets. In our VB.NET program, we use XLSXPage to represent one Excel document worksheet and the super class of XLSXPage is REPage.

VB.NET Demo Code for Generating Excel Doc

'''<summary>
''' Create an empty excel document
'''</summary>
'''<returns></returns>
Public Function CreateXLSXDocument() As XLSXDocument

Return New XLSXDocument()

End Function
In the above VB.NET demo code, CreateXLSXDocument method is used to create a blank Excel document.
Load Excel Document
Using the following APIs and sample codes, developers can easily load existing Excel document from load file or stream in VB.NET project.

APIs for Loading Excel Doc from Local File or Stream

Private Sub New(filePath As [String])
End Sub
Private Sub New(sourceStream As Stream)
End Sub
The first API is used to load target Excel document from local file with specific path and the second API can be used to directly load Excel document from stream.

VB.NET Sample Codes for Loading Excel Doc

'''<summary>
''' Load XLSXDocument from native file format
'''</summary>
'''<param name="filePath"></param>
'''<returns></returns>
Public Function LoadXLSXDocumentFromFile(filePath As [String]) As XLSXDocument

Return New XLSXDocument(filePath)

End Function
'''<summary>
''' Load XLSXDocument from memory stream
'''</summary>
'''<param name="filePath"></param>
'''<returns></returns>
Public Function LoadXLSXDocumentFromStream(sourceStream As Stream) As XLSXDocument

Return New XLSXDocument(sourceStream)

End Function
If you have an Excel document stored in the local file, you may use the first VB.NET sample code to get the Excel document from local file. If your target Excel document is saved in stream, you can copy the second sample code to your VB.NET project to obtain the Excel document.

API and Demo Code to Count Excel Document Page(s)

Once you have finished loading Excel document with the above method, you can use the following API and demo code to get the total number of the loaded Excel document by using GetPageCount method in VB.NET application.
Private Function GetPageCount() As Integer Implements XLSXDocument.GetPageCount
End Function
'''<summary>
''' Get page(Sheet) count of an XLSXDocument object
'''</summary>
'''<param name="doc"></param>
'''<returns></returns>
Public Function GetPageCount(doc As XLSXDocument) As Integer

Return doc.GetPageCount()

End Function
Save Microsoft Excel Doc
With our VB.NET Excel Reading SDK, you can save your Microsoft Excel document either to local file or to stream through VB.NET programming. APIs and sample codes to be used are shown below.

APIs to Save Excel Document to Native File or Stream

Private Sub Save(filePath As [String]) Implements XLSXDocument.Save
End Sub
Private Sub Save(s As Stream) Implements XLSXDocument.Save
End Sub
APIs above can be utilized to save your Excel document to native file and memory stream respectively.

Demo Codes for Saving Excel Document in VB.NET

'''<summary>
''' Save XLSXDocument object to file in the native file format
'''</summary>
'''<param name="doc"></param>
'''<param name="filePath"></param>

Public Sub SaveXLSXDocument(doc As XLSXDocument, filePath As [String])

doc.Save(filePath)

End Sub
'''<summary>
''' Save XLSXDocument to stream
'''</summary>
'''<param name="doc"></param>
'''<param name="s"></param>
Public Sub SaveXLSXDocument(doc As XLSXDocument, s As Stream)

doc.Save(s)

End Sub
For VB.NET developers who what to save Excel document to native file, the first demo code is suitable. And the other demo code is generally used to save Excel document to memory stream.


Recommend this to Google+


RasterEdge.com is professional provider of ASP.NET MVC Document Viewer, ASP.NET PDF Viewer, MVC PDF Viewer document, content and imaging solutions, available for ASP.NET AJAX, Silverlight, Windows Forms as well as WPF. We are dedicated to provide powerful & profession imaging controls, PDF document, image to pdf files and components for capturing, viewing, processing, converting, compressing and stroing images, documents and more.

©2000-2017 Raster Edge.com