2012-08-27 3 views
4

사용자가 실수로 .csv로 표시된 Excel 파일을 업로드했는지 감지하고 싶습니다. xls 파일을위한 표준 바이너리 풋 프린트가 가능합니까?.csv 파일이 실제로 .xls (Excel) 파일인지 확인합니다.

+0

어떤 프로그래밍 언어를 사용하고 있습니까? –

+0

대부분의 경우 js (노드)와 파이썬이 있지만 작동하는 모든 것을 사용하면 문제가 없습니다. – Rafael

답변

1

당신은 파이썬에서 엑셀 파일을 읽을 수 있습니다 :

http://scienceoss.com/read-excel-files-from-python/

당신은 Perl로 엑셀 파일을 읽을 수 있습니다 : file

http://www.thegeekstuff.com/2011/12/perl-and-excel/

How can I read Excel files in Perl?

유닉스/리눅스 유틸리티를 엑셀과 많은 수의 다른 파일을 인식합니다.

샘플 출력 :

file ~/Download/*xls

/home/paul/Downloads/REDACTED1.xls:   Composite Document File V2 Document, Little Endian, Os: Windows, Version 5.1, Code page: 1252, Author: Someones Name, Last Saved By: Somebody Else, Name of Creating Application: Microsoft Excel, Create Time/Date: Wed Jan 27 00:39:46 2010, Last Saved Time/Date: Sun Feb 28 13:55:47 2010, Security: 0 

/home/paul/Downloads/REDACTED2.xls: Composite Document File V2 Document, Little Endian, Os: Windows, Version 1.0, Code page: -535, Author: Paul , Last Saved By: Paul , Revision Number: 3, Total Editing Time: 18:09, Create Time/Date: Wed Oct 26 23:45:51 2011, Last Saved Time/Date: Thu Oct 27 00:34:42 2011 

당신은 단순히 file를 호출하고 결과를 반환하는 라이브러리를 구축 할 수 있습니다.

file은 소스 코드를 사용할 수 있으며 file 유틸리티는 자체 구성 파일과 마법 바이트 및 문자열 정보의 구성 디렉토리가 있습니다.

apt-get source file

./file-5.11/magic/MagDir 내 자신의 스캔에서 본 형식의 대형 다양한 찾기 위해 마법 바이트 문자열의 전체 디렉토리하지만 "복합 문서 파일"입니다 파일을 엑셀로 선언하지 않았습니다. 이 dir에는 Mac, Word 및 일부 구형 msdos 형식의 Excel 용 정의 파일이 있습니다.

cd ./file-5.11; grep 'Composite Document File' */*

수율 : 나는 file 유틸리티는 마이크로 소프트 엑셀 형식의 일부를 감지 할 수있는 방법을 결정하기 위해 조사 할 수 제안

src/cdf.c: * Parse Composite Document Files, the format used in Microsoft Office 
src/cdf.c: * N.B. This is the "Composite Document File" format, and not the 
src/cdf.h: * Parse Composite Document Files, the format used in Microsoft Office 
src/cdf.h: * N.B. This is the "Composite Document File" format, and not the 
src/readcdf.c:    if (file_printf(ms, "Composite Document File V2 Document") 
src/readcdf.c:   if (file_printf(ms, "Composite Document File V2 Document") 

.

관련 문제