Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Spreadsheet .NET
>
Tutorial
> Display Cell Values - Solution I
The following example shows you how to display values from all cells.
C# example
using System; using System.Collections.Generic; using Independentsoft.Office; using Independentsoft.Office.Spreadsheet; namespace Sample { class Program { static void Main(string[] args) { Workbook book = new Workbook("c:\\test\\input.xlsx"); foreach (Sheet sheet in book.Sheets) { if (sheet is Worksheet) { Worksheet worksheet = (Worksheet)sheet; IList
cells = worksheet.GetCells(); for (int i = 0; i < cells.Count; i++) { Console.WriteLine(cells[i].Reference + " = " + cells[i].Value); } } } Console.Read(); } } }
VB example
Imports System Imports System.Collections.Generic Imports Independentsoft.Office Imports Independentsoft.Office.Spreadsheet Module Module1 Sub Main(ByVal args As String()) Dim book As New Workbook("c:\test\input.xlsx") For Each sheet As Sheet In book.Sheets If TypeOf sheet Is Worksheet Then Dim worksheet As Worksheet = DirectCast(sheet, Worksheet) Dim cells As IList(Of Cell) = worksheet.GetCells() For i As Integer = 0 To cells.Count - 1 Console.WriteLine(cells(i).Reference + " = " + cells(i).Value) Next End If Next Console.Read() End Sub End Module
Need help? Ask our developers:
Name*
Email*
Message*