简体   繁体   English

c# dot net core中如何识别一个从.DLL文件转换过来的excel文件(xls, xlsx, csv)

[英]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.

相关问题 如何从 C#.Net Core 中重命名的 GZIP 文件中找出原始文件名 - How To Find Out The Original Filename From A GZIP File In C# .Net Core Which Has Been Renamed 将Excel文件(XLS或XLSX)转换为CSV文件 - Convert excel file (xls or xlsx) to csv file 通过linq从数据库导入和导出excel文件(csv,xls和xlsx) - import and export excel file (csv, xls and xlsx) from database by linq 如何使用C#从远程位置读取Excel csv或xls文件的行到ASP.NET应用程序中? - How can I read the rows of an Excel csv or xls file into an ASP.NET app from a remote location using C#? 如何将 .xls 转换为 .xlsx C#(.net 核心) - How to convert .xls to .xlsx C# (.net core) 如何在不安装 Microsoft Office 的情况下在 C# 中创建 Excel(.XLS 和 .XLSX)文件? - How do I create an Excel (.XLS and .XLSX) file in C# without installing Microsoft Office? 使用C#从.xls / .xlsx文件读取整行 - Reading an entire row from a .xls/.xlsx file with c# C#XLS和XLSX文件导入 - c# xls and xlsx file import 如何在C#中使用Syncfusion转换xls / xlsx文件 - How to convert a xls/xlsx file using Syncfusion in C# 将ibfs(从网站下载的Excel文件)文件转换为.xls / .xlsx文件格式,而无需使用C#Asp.net Web应用程序安装Office - Converting ibfs (Downloaded Excel files from websites) files to .xls/.xlsx file format without installing Office using C# Asp.net Web application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM