private static ConcurrentDictionary cellValues = new ConcurrentDictionary();
private static ConcurrentDictionary cellIndexCache = new ConcurrentDictionary();
public static void 多工作簿汇总NPOI2(string folderPath1, ListView.ListViewItemCollection items)
{
try
{
string folderPath = @"G:\000Excel测试文件\三个工作簿"; //三个工作簿 //N个工作簿汇总计算
List cellAddresses = new List();
List> cellAddSplited = new List>();
List shtNameList = new List();
cellValues.Clear();
foreach (ListViewItem item in items)
{
string value1 = item.SubItems[2].Text;
cellAddresses.Add(value1);
string valsplit = item.SubItems[2].Text;
List tem = 处理单元格区域无返回(valsplit);
cellAddSplited.Add(tem);
string value2 = item.SubItems[1].Text;
shtNameList.Add(value2);
}
if (cellIndexCache.Count == 0)
{
for (int i = 0; i
{
IWorkbook workbook = null;
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
if (filePath.EndsWith(".xlsx", StringComparison.OrdinalIgnoreCase))
{
workbook = new XSSFWorkbook(fs); // 处理 .xlsx 文件
}
else if (filePath.EndsWith(".xls", StringComparison.OrdinalIgnoreCase))
{
workbook = new HSSFWorkbook(fs); // 处理 .xls 文件
}
else
{
return;
}
for (int j = 0; j 处理单元格区域无返回(string input)
{
List cellList = new List();
string[] parts = input.Split(',');
foreach (string part in parts)
{
if (part.Contains(":"))
{
string[] range = part.Split(':');
string startCell = range[0];
string endCell = range[1];
string startColumn = ExtractColumn(startCell);
int startRow = ExtractRow(startCell);
string endColumn = ExtractColumn(endCell);
int endRow = ExtractRow(endCell);
for (int row = startRow; row 处理单元格区域(string input)
{
List cellList = new List();
string[] parts = input.Split(',');
foreach (string part in parts)
{
if (part.Contains(":"))
{
string[] range = part.Split(':');
string startCell = range[0];
string endCell = range[1];
string startColumn = ExtractColumn(startCell);
int startRow = ExtractRow(startCell);
string endColumn = ExtractColumn(endCell);
int endRow = ExtractRow(endCell);
for (int row = startRow; row = 0 && digitIndex