无尘阁日记

无尘阁日记

用户反馈问题无法登陆
2026-03-17

我问:

2026-03-16 15:23:00.7647 [ERROR]: ExcelHelperByOpenxml.GetProperty:System.Object[]

The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

EPPlus   在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:23:00.7647 [ERROR]: System.IO.InvalidDataException: The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:23:24.8343 [ERROR]: ExcelHelperByOpenxml.GetProperty:System.Object[]

The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

EPPlus   在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:23:24.8343 [ERROR]: System.IO.InvalidDataException: The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:24:38.7979 [ERROR]: ExcelHelperByOpenxml.GetProperty:System.Object[]

The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

EPPlus   在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:24:38.7979 [ERROR]: System.IO.InvalidDataException: The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:24:38.8394 [ERROR]: ExcelHelperByOpenxml.GetProperty:System.Object[]

不支持给定路径的格式。

mscorlib   在 System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)

在 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)

在 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:24:38.8394 [ERROR]: System.NotSupportedException: 不支持给定路径的格式。

在 System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)

在 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)

在 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:25:33.8215 [ERROR]: ExcelHelperByOpenxml.GetProperty:System.Object[]

The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

EPPlus   在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:25:33.8215 [ERROR]: System.IO.InvalidDataException: The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:28:42.0672 [ERROR]: ExcelHelperByOpenxml.GetProperty:System.Object[]

The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

EPPlus   在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:28:42.0672 [ERROR]: System.IO.InvalidDataException: The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:32:46.5965 [ERROR]: ExcelHelperByOpenxml.GetProperty:System.Object[]

The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

EPPlus   在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:32:46.5965 [ERROR]: System.IO.InvalidDataException: The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:37:02.9132 [ERROR]: ExcelHelperByOpenxml.GetProperty:System.Object[]

The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

EPPlus   在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:37:02.9132 [ERROR]: System.IO.InvalidDataException: The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:42:42.9397 [ERROR]: ExcelHelperByOpenxml.GetProperty:System.Object[]

The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

EPPlus   在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


2026-03-16 15:42:42.9397 [ERROR]: System.IO.InvalidDataException: The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

在 OfficeOpenXml.Packaging.ZipPackage..ctor(Stream stream)

在 OfficeOpenXml.ExcelPackage.Load(Stream input, Stream output, String Password)

在 OfficeOpenXml.ExcelPackage..ctor(Stream newStream)

在 TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)


这啥意思,用户说登陆不了我们的工作站。

AI答:

这段报错的核心意思是:

你的程序在“读取某个 Excel 文件属性”的时候失败了,而且失败得很明确:它拿到的东西,不是一个 EPPlus 能正常打开的 Excel 包文件。

先说结论:

这大概率不是“账号密码校验本身出错”,而是“登录流程里依赖了某个 Excel 文件”,而这个文件要么不是标准的 .xlsx,要么已经损坏了,要么其实是加密文件,要么传进去的根本不是一个合法文件路径。结果就是登录流程中断,所以用户感觉成了“工作站登不上”。

下面我给你拆开讲。

一、这两类错误分别是什么意思

1. InvalidDataException:文件不是有效的 Package 文件

日志里反复出现这句:

The file is not a valid Package file. If the file is encrypted, please supply the password in the constructor.

这句话翻成大白话就是:

EPPlus 只会正确读取基于 OpenXML 的 Excel,也就是 .xlsx 这种本质上是 zip 包结构的文件。
但你传给它的文件,打开后发现根本不是这种格式,所以它没法读。

常见原因有这几种:

第一种:文件后缀是 xlsx,但内容其实不是 xlsx

最常见。

比如:

  • 其实是 .xls 老格式

  • 其实是一个 html/csv/txt,被人改名成 .xlsx

  • 其实是下载失败后的错误页,被保存成 Excel 文件

  • 其实是接口返回的 JSON/HTML,却被当成 Excel 落盘了

也就是说,名字像 Excel,内容不是 Excel。

第二种:文件损坏了

例如:

  • 上传时没传完整

  • 网络中断导致文件写了一半

  • 文件流还没写完就被读取

  • 另一个线程正在覆盖这个文件

这种情况下,EPPlus 去解压内部结构时,发现包结构不完整,就会报这个错。

第三种:文件被加密了

如果用户上传的是“设置了打开密码”的 Excel,EPPlus 不传密码就打不开,也会报这个错。

但从经验上看,你这里“连续反复报错”,更像前两种,不太像真的是用户每次都在传一个加密文件。

2. NotSupportedException:不支持给定路径的格式

日志里还有一条不一样的:

System.NotSupportedException: 不支持给定路径的格式。

这个意思不是文件内容错,而是:

传给 FileStreamexcelFileName 根本就不是一个合法的本地文件路径。

比如可能传入了这些东西:

  • 一个 URL:http://...

  • 一个 Base64 字符串

  • 一个空字符串

  • 一个带非法字符的路径

  • 一个前端传来的相对路径/虚拟路径

  • 一个对象转字符串后的内容,不是真路径

也就是说,程序以为它拿到的是“磁盘路径”,结果根本不是。

这条错误很关键,它说明你的问题不只是“文件内容不对”,还很可能有“上游传参就错了”。

二、它和“用户登录不了工作站”是什么关系

从日志看,报错方法是:

TJ.Common.ExcelHelperByOpenxml.GetProperty(String excelFileName, String propertyName)

这说明登录流程里,某个环节调用了“读取 Excel 属性”的公共方法。

这就意味着,用户登录工作站时,系统很可能做了下面某种事情:

1. 登录时要校验某个本地 Excel 模板/配置文件

比如工作站启动后会读取:

  • 本地模板文件

  • 授权文件

  • 工作站配置 Excel

  • 初始化参数 Excel

  • 用户环境检测文件

如果这个文件损坏或路径不对,登录流程就可能卡死或失败。

2. 登录后自动读取用户最近项目或本地缓存文件

有些系统不是纯账号登录,而是登录后还要恢复工作台状态,比如:

  • 打开上次项目

  • 读取最近使用的 Excel

  • 检查底稿模板

  • 读取插件绑定文件

如果这里异常没被兜住,前端就会把它表现成“登录失败”。

3. 工作站本质依赖 Excel 插件或底稿环境

你们这个业务场景里,很像是资产评估工作站、底稿系统、Excel 插件联动场景。
这种系统很多“登录工作站”其实不是纯 web 登录,而是:

“登录账号 + 检查本地 Office/模板/底稿环境 + 初始化插件”

只要初始化阶段某个 Excel 文件出问题,用户就会觉得是“登不上”。

所以从业务感觉上说:

用户说的是“登录不了”,
技术真因可能是“登录后的本地环境初始化失败”。

三、从日志特征看,更像什么问题

从你贴的时间序列看,我更倾向于这几个判断。

1. 某个固定文件反复被读取失败

同一天下午多次报同样错误,说明不是偶发抖动,而是:

  • 某个固定文件本身有问题

  • 或某段固定逻辑一直拿错文件

这更像“环境级问题”,不是单次用户误操作。

2. 中间夹杂了一次路径格式错误

15:24:38 那次出现了“路径格式不支持”。

这很像两种情况:

情况A:系统有时拿到的是路径,有时拿到的是别的字符串

比如某个字段本来应该存文件全路径,但有时存了:

  • URL

  • 文件ID

  • JSON

  • 空值

  • 未解码字符串

情况B:代码里做了回退逻辑

例如:
第一次读真实文件失败,
然后又尝试去读另一个“候选路径”,结果这个候选值压根不是路径。

所以这进一步说明:
问题不一定只在文件本身,也可能在文件来源字段。

3. 很像旧版 xls / 假 xlsx / 损坏缓存文件

EPPlus 只能很好处理 .xlsx
如果你们工作站某处还会拿 .xls 文件,却统一走了 OpenXml/EPPlus 逻辑,那就会稳定报这个错。

这个在老系统里非常常见:

  • 老底稿模板还是 .xls

  • 新代码统一按 .xlsx 读取

  • 一读就炸

四、你现在最该查什么

下面按优先级给你排。

一层:先定位到底是哪个文件

你现在日志只看到方法名,没有看到最关键的东西:excelFileName 到底是什么。

你应该立刻在 GetProperty 方法入口加日志,至少打出:

  • excelFileName

  • propertyName

  • File.Exists(excelFileName)

  • 文件扩展名

  • 文件大小

  • 如果存在,最好记录前几个字节特征

最少先加这个:

logger.Error($"GetProperty excelFileName={excelFileName}, propertyName={propertyName}");

再补:

logger.Error($"File.Exists={File.Exists(excelFileName)}");

因为现在你还只是“看到症状”,没看到病灶。

二层:确认这个文件到底是不是标准 xlsx

你可以人工去服务器或用户机器上检查这个文件:

1. 看后缀

是不是 .xlsx

2. 改成 .zip 能不能打开

真正的 xlsx 本质是 zip 包。
如果改后缀成 .zip 完全打不开,基本就不是标准 xlsx。

3. 用 Excel 手工打开

如果 Excel 自己都提示修复、格式不对、文件损坏,那就坐实了。

4. 看文件大小

如果是 0KB、几KB、或者异常小,很可能写坏了。

三层:确认是不是传错了路径

特别是针对这条:

不支持给定路径的格式

你要重点核查调用 GetProperty(excelFileName, propertyName) 的上游来源,看看 excelFileName 是从哪里来的:

  • 数据库字段?

  • 配置文件?

  • 前端传参?

  • 下载接口返回值?

  • 临时文件路径?

  • 用户最近打开记录?

重点看有没有这几类错误值:

  • http://xx

  • /upload/xx

  • {"path":"..."}

  • null

  • 空字符串

  • 含有非法字符

  • 不是本机绝对路径

五、从代码层面,这个方法本身也该补强

你现在这个公共方法明显太“相信输入”了。
只要上游有一点脏数据,它就直接抛异常,把整个登录链路拖死。

建议你把它改成“先校验,再读取,再兜底”。

1. 先校验路径合法性

  • 非空

  • 是不是本地路径

  • 文件是否存在

2. 再校验扩展名

至少区分:

  • .xlsx

  • .xls

  • 其他

如果是 .xls,别走 EPPlus,应该走 NPOI 或其他兼容旧格式的方案。

3. 对加密文件单独识别

如果业务允许密码文件,要有单独逻辑;
如果业务不允许,直接返回明确错误:“文件已加密,系统不支持读取”。

4. 登录场景不要被 Excel 读取异常直接拖死

如果这是登录后的附属动作,不该因为一个模板文件坏了就让整个工作站登录失败。
应该改成:

  • 登录成功

  • 但提示“本地模板读取失败”或“初始化底稿环境失败”

也就是说,主链路和附属链路要拆开。

六、你可以怎么跟业务或客服解释

你可以这样对外说,比较准确:

“目前看不是用户账号密码错误,而是工作站登录后的本地 Excel 文件读取异常。系统在初始化过程中尝试读取某个 Excel 文件,但该文件格式不正确、已损坏、被加密,或文件路径本身非法,导致登录流程中断。需要进一步定位具体是哪个文件和哪个路径。”

这句话既不甩锅给用户,也说清楚了技术本质。

七、我给你的最终判断

结合你贴的日志,我的判断是:

核心原因

工作站登录过程中调用了 ExcelHelperByOpenxml.GetProperty,去读取某个 Excel 文件属性,但传入的文件或路径有问题。

最可能的三类真因

第一类:文件不是标准 xlsx

例如旧版 xls、伪装成 xlsx 的其他文件、接口异常页、损坏文件。

第二类:传入的不是合法本地路径

例如 URL、空值、错误字符串、数据库里存脏数据。

第三类:本地缓存/模板文件损坏

尤其像工作站、Excel 插件、底稿系统这类场景,非常常见。

和“登录不了”的关系

不是登录认证逻辑本身报错,而是登录后的环境初始化依赖 Excel 文件,结果初始化失败,最终表现成“工作站无法登录”。

八、你下一步最值钱的动作

你现在别急着先改大逻辑,先做这三件事最有效:

1. 立刻把 excelFileName 原值打出来

这是第一优先级。

2. 查这几个时间点对应的是哪位用户、哪台机器、哪个文件

把“用户登录失败”与“具体文件”对应上。

3. 检查这个方法调用链

找到是谁在登录过程中调用了 GetProperty,看看它为什么在这个阶段必须读 Excel。

你把 ExcelHelperByOpenxml.GetProperty 这个方法代码,连同它的调用处一起贴给我,我可以直接帮你判断是“路径错了”“文件格式错了”,还是“登录流程设计有问题”,并顺手帮你改成更稳的版本。