主要更新了http相关的内容

This commit is contained in:
2025-11-18 19:54:13 +08:00
parent bf464b04a6
commit 5762b6daf4
13 changed files with 155 additions and 136 deletions

View File

@@ -1,11 +1,6 @@
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ramitta.lib
{
@@ -85,8 +80,8 @@ namespace Ramitta.lib
}
public static Dictionary<string, List<string>> ReadExcelAsDictCol(
string filePath,
object sheetName = null,
string filePath,
object sheetName = null,
List<string> headerInit = null)
{
var result = new Dictionary<string, List<string>>();
@@ -166,23 +161,55 @@ namespace Ramitta.lib
return true;
}
public static ICell? getRowCell(ISheet sheet, int rowIndex, int cellIndex)
public static ICell? getRowCell(ISheet sheet, int rowIndex, object cellIndex)
{
int actualCellIndex = 0;
if (cellIndex is int intIndex)
{
// 如果输入是数字,直接使用
actualCellIndex = intIndex;
}
else if (cellIndex is string strIndex)
{
actualCellIndex = ColToIndex(strIndex);
}
else
{
return null;
}
IRow row = sheet.GetRow(rowIndex);
if (row == null) return null;
ICell cell = row.GetCell(cellIndex);
ICell cell = row.GetCell(actualCellIndex);
if (cell == null) return null;
return cell;
}
public static String? getRowCellStr(ISheet sheet, int rowIndex, int cellIndex)
public static String? getRowCellStr(ISheet sheet, int rowIndex, object cellIndex)
{
var cellValue = getRowCell(sheet, rowIndex, cellIndex)?.ToString();
int actualCellIndex = 0;
if (cellIndex is int intIndex)
{
// 如果输入是数字,直接使用
actualCellIndex = intIndex;
}
else if (cellIndex is string strIndex)
{
actualCellIndex = ColToIndex(strIndex);
}
else
{
return null;
}
var cellValue = getRowCell(sheet, rowIndex, actualCellIndex)?.ToString();
return string.IsNullOrWhiteSpace(cellValue) ? null : cellValue;
}
// 简短版本
// 简短版本
// 列名字转为列号
public static int ColToIndex(string col)
{
return col.ToUpper().Aggregate(0, (cur, ch) => cur * 26 + (ch - 'A'));