MeshWeaver.DataSetReader.Excel.Utils
2.0.3
See the version list below for details.
dotnet add package MeshWeaver.DataSetReader.Excel.Utils --version 2.0.3
NuGet\Install-Package MeshWeaver.DataSetReader.Excel.Utils -Version 2.0.3
<PackageReference Include="MeshWeaver.DataSetReader.Excel.Utils" Version="2.0.3" />
<PackageVersion Include="MeshWeaver.DataSetReader.Excel.Utils" Version="2.0.3" />
<PackageReference Include="MeshWeaver.DataSetReader.Excel.Utils" />
paket add MeshWeaver.DataSetReader.Excel.Utils --version 2.0.3
#r "nuget: MeshWeaver.DataSetReader.Excel.Utils, 2.0.3"
#addin nuget:?package=MeshWeaver.DataSetReader.Excel.Utils&version=2.0.3
#tool nuget:?package=MeshWeaver.DataSetReader.Excel.Utils&version=2.0.3
MeshWeaver.DataSetReader.Excel.Utils
MeshWeaver.DataSetReader.Excel.Utils is a utility library that provides common functionality and abstractions for Excel file reading in the MeshWeaver ecosystem. It serves as the foundation for both binary (.xls) and OpenXML (.xlsx) format readers.
Overview
The library provides:
- Core interfaces for Excel data reading
- Common utility functions for Excel data processing
- Error handling and exception types
- ZIP archive handling for OpenXML formats
- Format conversion utilities
- Data type management
Core Components
IExcelDataReader Interface
The main interface for Excel data reading implementations:
public interface IExcelDataReader : IDataReader
{
void Initialize(Stream fileStream);
DataSet AsDataSet();
DataSet AsDataSet(bool convertOADateTime);
bool IsValid { get; }
string Name { get; }
int ResultsCount { get; }
bool IsFirstRowAsColumnNames { get; set; }
}
Utility Functions
Data Conversion
public static class Helpers
{
// Convert Excel OLE Automation date to DateTime
public static object ConvertFromOATime(double value);
// Convert escaped characters in strings
public static string ConvertEscapeChars(string input);
// Convert Int64 bits to double (for binary formats)
public static double Int64BitsToDouble(long value);
}
Data Type Management
public static class Helpers
{
// Fix and optimize data types in DataSet
public static void FixDataTypes(DataSet dataset);
// Handle duplicate column names
public static void AddColumnHandleDuplicate(DataTable table, string columnName);
}
ZIP Archive Handling
public class ZipWorker
{
// Access workbook and shared strings streams
public Stream GetWorkbookStream();
public Stream GetSharedStringsStream();
public Stream GetStylesStream();
}
Constants and Formats
public static class ExcelConstants
{
// Common Excel format constants
public const int MaxWorksheetColumns = 16384;
public const int MaxWorksheetRows = 1048576;
public const int MaxWorksheetNameLength = 31;
}
Error Handling
Exception Types
BiffRecordException
- For BIFF record parsing errorsHeaderException
- For header parsing errorsExcelReaderException
- Base exception for Excel reading errors
Error Messages
public static class Errors
{
public const string InvalidPassword = "Invalid password";
public const string InvalidFile = "Invalid file";
public const string NotSupported = "Not supported";
}
Features
Format Support
- Binary (.xls) format utilities
- OpenXML (.xlsx) format utilities
- Common abstractions for both formats
Data Processing
- Stream-based reading
- Data type inference
- Column name handling
- Date/time conversion
- Character encoding support
Error Handling
- Specialized exception types
- Validation checks
- Error messages
- Recovery mechanisms
Performance Optimizations
- Efficient data type handling
- Stream management
- Memory optimization
- Resource cleanup
Best Practices
Resource Management
using (var stream = File.OpenRead("data.xlsx")) { var reader = new ExcelReader(); reader.Initialize(stream); // Process data }
Data Type Handling
var dataset = reader.AsDataSet(); Helpers.FixDataTypes(dataset); // Optimize data types
Error Handling
try { reader.Initialize(stream); if (!reader.IsValid) throw new ExcelReaderException(reader.ExceptionMessage); } catch (BiffRecordException ex) { // Handle BIFF format errors }
Integration
With Excel Readers
public class ExcelReader : IExcelDataReader
{
protected readonly ZipWorker ZipWorker;
public void Initialize(Stream stream)
{
ZipWorker.Initialize(stream);
// Initialize reader
}
}
With Message Hub
services.AddMessageHub(hub => hub
.ConfigureServices(services => services
.AddTransient<IExcelDataReader, ExcelReader>()
)
);
Related Projects
- MeshWeaver.DataSetReader.Excel - Base Excel reader framework
- MeshWeaver.DataSetReader.Excel.BinaryFormat - Legacy Excel format implementation
- MeshWeaver.DataSetReader.Excel.OpenXmlFormat - Modern Excel format implementation
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
-
net9.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on MeshWeaver.DataSetReader.Excel.Utils:
Package | Downloads |
---|---|
MeshWeaver.DataSetReader.Excel.OpenXmlFormat
Package Description |
|
MeshWeaver.DataSetReader.Excel.BinaryFormat
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.1.0 | 154 | 9 days ago |
2.0.3 | 482 | 22 days ago |
2.0.2 | 461 | 22 days ago |
2.0.1 | 115 | 25 days ago |
2.0.0 | 149 | a month ago |
2.0.0-preview3 | 101 | 2 months ago |
2.0.0-Preview2 | 117 | 2 months ago |
2.0.0-preview1 | 106 | 3 months ago |
1.0.1 | 148 | 6 months ago |
1.0.0 | 125 | 6 months ago |