mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
34 lines
735 B
C#
34 lines
735 B
C#
#if TENGINE_NET
|
|
using OfficeOpenXml;
|
|
|
|
namespace TEngine.Helper;
|
|
|
|
public static class ExcelHelper
|
|
{
|
|
public static ExcelPackage LoadExcel(string name)
|
|
{
|
|
return new ExcelPackage(name);
|
|
}
|
|
|
|
public static string GetCellValue(this ExcelWorksheet sheet, int row, int column)
|
|
{
|
|
ExcelRange cell = sheet.Cells[row, column];
|
|
|
|
try
|
|
{
|
|
if (cell.Value == null)
|
|
{
|
|
return "";
|
|
}
|
|
|
|
string s = cell.GetValue<string>();
|
|
|
|
return s.Trim();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new Exception($"Rows {row} Columns {column} Content {cell.Text} {e}");
|
|
}
|
|
}
|
|
}
|
|
#endif |