From 69c246e54e4d86245c77044ac411747d51a2fd12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B0=E6=97=A0=E6=AD=A2=E7=AB=9E?= <734913414@qq.com> Date: Mon, 26 Dec 2022 16:13:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DNPOI=E8=A7=A3=E6=9E=90xls?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=86=85=E5=AE=B9=E6=9C=89=E8=AF=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TextLocator/Service/ExcelFileService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TextLocator/Service/ExcelFileService.cs b/TextLocator/Service/ExcelFileService.cs index 1b9f9cf..bca3e3e 100644 --- a/TextLocator/Service/ExcelFileService.cs +++ b/TextLocator/Service/ExcelFileService.cs @@ -199,7 +199,7 @@ namespace TextLocator.Service int cellCount = row.LastCellNum; for (int k = 0; k < cellCount; k++) { - builder.Append(row.GetCell(j) + " "); + builder.Append(row.GetCell(k) + " "); } builder.AppendLine(); } -- Gitee From 0bd3056ea83007fabedb7ebf5f15230017020434 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B0=E6=97=A0=E6=AD=A2=E7=AB=9E?= <734913414@qq.com> Date: Mon, 26 Dec 2022 16:15:17 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=BC=96=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E8=A7=A3=E5=8E=8B=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=97=B6=E4=B8=AD=E6=96=87=E4=B9=B1=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TextLocator/Service/ZipFileService.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/TextLocator/Service/ZipFileService.cs b/TextLocator/Service/ZipFileService.cs index 9d65931..94a2443 100644 --- a/TextLocator/Service/ZipFileService.cs +++ b/TextLocator/Service/ZipFileService.cs @@ -1,6 +1,7 @@ using log4net; using SharpCompress.Archives; using SharpCompress.Common; +using SharpCompress.Readers; using System; using System.Collections.Generic; using System.IO; @@ -44,10 +45,18 @@ namespace TextLocator.Service builder.Append(" 大小:" + FileUtil.GetFileSizeFriendly(fileInfo.Length)); builder.Append(" 列表:=> \r\n"); + // 解析列表 using (FileStream file = File.OpenRead(filePath)) { - using (var archive = ArchiveFactory.Open(file)) + //设置编码,解决解压文件时中文乱码 + var archiveEncoding = new ArchiveEncoding(); + archiveEncoding.Default = System.Text.Encoding.GetEncoding("gbk"); + var options = new ReaderOptions + { + ArchiveEncoding = archiveEncoding + }; + using (var archive = ArchiveFactory.Open(file, options)) { foreach (var entry in archive.Entries) { -- Gitee