GroupDocs.Parser for .NET 24.8 Release Notes
This page contains release notes for GroupDocs.Parser for .NET 24.8
Full List of Issues Covering all Changes in this Release
Key | Summary | Category |
---|---|---|
PARSERNET-2400 | Implement the ability to extract sheets from spreadsheets | Feature |
Public API and Backward Incompatible Changes
Implement the ability to extract sheets from spreadsheets
Description
This feature allows to extract cells from spreadsheets.
Public API changes
Parser public class was updated with changes as follows:
- GetWorksheetInfo() public method was added.
- GetWorksheetInfo(int) public method was added.
- GetWorksheetCells(int) public method was added.
- GetWorksheetCells(int, WorksheetOptions) public method was added.
Features public class was updated with changes as follows:
- Worksheet public property was added.
Added WorksheetCell public class.
Added WorksheetInfo public class.
Added WorksheetRange public class.
Added WorksheetOptions public class.
Usage
The following example shows how to extract cells from spreadsheet:
// Create an instance of Parser class
using (Parser parser = new Parser(Constants.SampleXlsx))
{
// Check if worksheet cells extraction is supported
if (!parser.Features.Worksheet)
{
throw new NotSupportedException("Worksheet cells extraction isn't supported.");
}
// Get the information about worksheets
IEnumerable<WorksheetInfo> info = parser.GetWorksheetInfo();
// Iterate over worksheet information
foreach(WorksheetInfo i in info)
{
// Print the worksheet name
Console.WriteLine(i.Name);
Console.WriteLine();
// Get the worksheet cells
IEnumerable<WorksheetCell> cells = parser.GetWorksheetCells(i.Index);
// Iterate over cells
foreach (WorksheetCell c in cells)
{
// Print the cell information and text value
Console.WriteLine($"Row: {c.RowIndex} Column: {c.ColumnIndex} RowSpan: {c.RowSpan} ColumnSpan: {c.ColumnSpan}");
Console.WriteLine(c.Text);
Console.WriteLine();
}
}
}
The following example shows how to extract cells from spreadsheet with customization:
// Create an instance of Parser class
using (Parser parser = new Parser(Constants.SampleXlsx))
{
// Check if worksheet cells extraction is supported
if (!parser.Features.Worksheet)
{
throw new NotSupportedException("Worksheet cells extraction isn't supported.");
}
// Get the information about the first worksheet
WorksheetInfo info = parser.GetWorksheetInfo(0);
// Print the worksheet name
Console.WriteLine(info.Name);
Console.WriteLine();
// Create the range that represents the first two rows
WorksheetRange range = new WorksheetRange(
info.MinRowIndex,
Math.Min(info.MinRowIndex + 1, info.MaxRowIndex),
info.MinColumnIndex,
info.MaxColumnIndex);
// Get the worksheet cells from the first two rows
IEnumerable<WorksheetCell> cells = parser.GetWorksheetCells(0, new WorksheetOptions(range));
// Iterate over cells
foreach (WorksheetCell c in cells)
{
// Print the cell information and text value
Console.WriteLine($"Row: {c.RowIndex} Column: {c.ColumnIndex} RowSpan: {c.RowSpan} ColumnSpan: {c.ColumnSpan}");
Console.WriteLine(c.Text);
Console.WriteLine();
}
}