[英]How to identify an excel file(xls, xlsx, csv) which has been converted from .DLL file in c# dot net core
Basically need to identify the excel is originally created from a valid excel.基本上需要识别excel最初是从一个有效的excel创建的。 I have tried using Microsoft.Interop.Excel File format.
我曾尝试使用 Microsoft.Interop.Excel 文件格式。 Seems like I cannot use this without Microsoft office being installed.
如果没有安装 Microsoft Office,我似乎无法使用它。 So need another approach for this problem.
所以需要另一种方法来解决这个问题。
EDIT : Basically I want to be able to distinguish a valid excel from invalid one like an excel file which is converted from DLL.编辑:基本上我希望能够区分有效的 excel 和无效的 excel,例如从 DLL 转换的 excel 文件。 Because the file extension will say it is xls.
因为文件扩展名会说它是 xls。 If you try to open that file, it will open an empty workbook without any sheets.
如果您尝试打开该文件,它将打开一个没有任何工作表的空工作簿。 But I cannot decide an excel with no sheets is an invalid one.
但我不能断定没有工作表的 excel 是无效的。
If you want to idenify wheter file is a valid excel file or not, you can use 'trid file identifier'.如果要确定文件是否为有效的 excel 文件,可以使用“trid 文件标识符”。 TrID - File Identifier .
TrID - 文件标识符。
You can do it own your own also by reading magic number or file signaure bytes.您也可以通过读取幻数或文件签名字节来自己做。 Please go through this question Original file bytes from StreamReader, magic number detection .
请通过这个问题来自 StreamReader 的原始文件字节,幻数检测。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.