public static void ReadExcelFile(string filePath)
{
try
{
// Validate file existence
if (!File.Exists(filePath))
{
throw new FileNotFoundException("The specified Excel file was not found.", filePath);
}
public static void ReadExcelFile(string filePath)
{
try
{
// Validate file existence
if (!File.Exists(filePath))
{
throw new FileNotFoundException("The specified Excel file was not found.", filePath);
}
// Set EPPlus license context
ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;
// Load the Excel file
using (var package = new ExcelPackage(new FileInfo(filePath)))
{
// Process all worksheets in the file
foreach (var worksheet in package.Workbook.Worksheets)
{
Console.WriteLine($"Reading content from worksheet: {worksheet.Name}");
// Check if the worksheet has content
if (worksheet.Dimension == null)
{
Console.WriteLine("The worksheet is empty.");
continue;
}
int rowCount = worksheet.Dimension.Rows;
int colCount = worksheet.Dimension.Columns;
// Read and display the content of the worksheet
for (int row = 1; row
Подробнее здесь: https://stackoverflow.com/questions/792 ... gth-actual
«Ошибка: длина («-2») должна быть неотрицательным значением. (Параметр «длина») Фактическое значение было -2». но если я ⇐ C#
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Таблица должна иметь максимальную ширину 200 пикселей, тогда только она должна быть обернута
Anonymous » » в форуме CSS - 0 Ответы
- 94 Просмотры
-
Последнее сообщение Anonymous
-