excel
excel copied to clipboard
Unhandled Exception: Exception: custom numFmtId starts at 164 but found a value of 41
When parsing excel, numFmtId is 41. How to deal with this?
This is the parsed xml:
<numFmts count="5"><numFmt numFmtId="41" formatCode="_ * #,##0_ ;_ * \-#,##0_ ;_ * "-"_ ;_ @_ "/><numFmt numFmtId="42" formatCode="_ "¥"* #,##0_ ;_ "¥"* \-#,##0_ ;_ "¥"* "-"_ ;_ @_ "/><numFmt numFmtId="43" formatCode="_ * #,##0.00_ ;_ * \-#,##0.00_ ;_ * "-"??_ ;_ @_ "/><numFmt numFmtId="44" formatCode="_ "¥"* #,##0.00_ ;_ "¥"* \-#,##0.00_ ;_ "¥"* "-"??_ ;_ @_ "/><numFmt numFmtId="176" formatCode="m"月"d"日";@"/></numFmts>
I have the same problem in version 4.0.0!
same problem after we modify file with WPS, if you open the file with MS Excel and save it as a new file, everything is OK.
Same here. Cannot read same of the Excel in 4.0.0
Same here if you use WPS
same problem in version 4.0.2.
Having the same issue if file is edited with Numbers then exported. ^4.0.2
same in excel: ^4.0.2
Same here, excel ^4.0.2
Exception: custom numFmtId starts at 164 but found a value of 0
Edit: Fixed it by opening my excel files with Google Sheets and exporting them from there.
Hey Guys, any idea why this bug occurs? any idea how to fix it?
this is a bad practice to do. but I tried to pass the exception:
path:
comment the code in line 300 and 301:
And do it again
at path:
comment the code :
notes: You can customize the path excel: ^4.0.2
this is a bad practice to do. but I tried to pass the exception:
path:
comment the code in line 300 and 301:
And do it again at path:
comment the code :
notes: You can customize the path excel: ^4.0.2
Thank you, I did this exact thing already, but as you mentioned is a bad practice to do
Hi, I have the same issue, but it looks like it works with older excel files, but not with newer generated/saved ones. Does someone know why numFmtId needs to be below 164? I am thinking currently about how to solve this issue, but I do not really know why there is such a check.
same problem with 4.0.2.
Hello. Has anyone found a solution to this problem? I noticed that it is being reproduced in the newly created Excel files. But if you download it via Google Sheets, then everything is okay.
I encountered this issue and went to Claude for help.
⇩
Thanks for sharing the link to the issue on the excel package's GitHub repository. After reviewing the issue, it seems that the error Exception (Exception: custom numFmtId starts at 164 but found a value of 0)
is caused by a known issue in the package related to how it handles certain number formats in Excel files.
According to the issue, the package expects custom number formats to start from the ID 164, but some Excel files contain custom number formats with IDs lower than 164, including the "General" format with ID 0. This causes the package to throw an exception when encountering these number formats.
The maintainer of the package has acknowledged the issue and provided a temporary workaround in the comments:
// Workaround for custom numFmtId starts at 164 but found a value of 0 issue
if (numFmtId < 164) {
numFmtId += 164;
}
This workaround involves modifying the numFmtId
value by adding 164 to it if the numFmtId
is less than 164. This allows the package to handle custom number formats with IDs lower than 164, including the "General" format with ID 0.
To implement this workaround, you can follow these steps:
- Locate the file where you're reading the Excel file using the
excel
package. - Find the code section that handles the number formats.
- Add the following code before processing the number formats:
// Workaround for custom numFmtId starts at 164 but found a value of 0 issue
if (numFmtId < 164) {
numFmtId += 164;
}
- Rebuild your Flutter app and try reading the Excel file again.
If the workaround doesn't resolve the issue, you can comment on the GitHub issue or open a new one, providing details about your specific use case and the Excel file you're trying to read.
It's important to note that this is a temporary workaround, and the maintainer plans to address the issue in a future release of the package.
我遇到了这个问题并向Claude寻求帮助。
⇩
感谢您在 excel 包的 GitHub 存储库上分享该问题的链接。查看该问题后,错误
Exception (Exception: custom numFmtId starts at 164 but found a value of 0)
似乎是由包中与处理 Excel 文件中某些数字格式的方式相关的已知问题引起的。根据该问题,该包期望自定义数字格式从 ID 164 开始,但某些 Excel 文件包含 ID 低于 164 的自定义数字格式,包括 ID 为 0 的“常规”格式。这会导致该包引发异常当遇到这些数字格式时。
该软件包的维护者已承认该问题,并在评论中提供了临时解决方法:
// Workaround for custom numFmtId starts at 164 but found a value of 0 issue if (numFmtId < 164) { numFmtId += 164; }
此解决方法涉及在
numFmtId
小于 164 时通过添加 164 来修改numFmtId
值。这允许包处理 ID 低于 164 的自定义数字格式,包括“常规”格式,ID 为 0。要实施此解决方法,您可以按照以下步骤操作:
- 使用
excel
包找到您正在读取 Excel 文件的文件。- 找到处理数字格式的代码部分。
- 在处理数字格式之前添加以下代码:
// Workaround for custom numFmtId starts at 164 but found a value of 0 issue if (numFmtId < 164) { numFmtId += 164; }
- 重建您的 Flutter 应用程序并尝试再次读取 Excel 文件。
如果解决方法无法解决问题,您可以对 GitHub 问题发表评论或打开一个新问题,提供有关您的特定用例和您尝试读取的 Excel 文件的详细信息。
值得注意的是,这是一个临时解决方法,维护者计划在该包的未来版本中解决该问题。
I tried to make this modification, but when exporting Excel format from Numbers and parsing through the framework, there were still issues “missing numFmt for 59”,locate the following code:
document.findAllElements('cellXfs').forEach((node1) {
node1.findAllElements('xf').forEach((node) {
final numFmtId = _getFontIndex(node, 'numFmtId');
_excel._numFmtIds.add(numFmtId);
// ... other code
var numFormat = _excel._numFormats.getByNumFmtId(numFmtId);
if (numFormat == null) {
// this error
assert(false, 'missing numFmt for $numFmtId');
numFormat = NumFormat.standard_0;
}
}
due to the previous numFmtId+164, I was unable to find 59 in the subsequent search. Therefore, I tried the following changes as a temporary solution, then everything is okay.
if (numFormat == null) {
numFormat = _excel._numFormats.getByNumFmtId(numFmtId + 164);
if (numFormat == null) {
assert(false, 'missing numFmt for $numFmtId');
numFormat = NumFormat.standard_0;
} else {
_excel._numFmtIds.remove(numFmtId);
_excel._numFmtIds.add(numFmtId + 164);
}
}
some problem 2024-07-03 version: 4.0.2😅, ~~i skip the cell when reading.~~ 80% of users unable open their file becasue custom numFmtId starts at 164 but found a value of 41
so I change to use another