puneet kumar
asked on
Differentiate format
how to check .xls file is based on xml or word file because in both extension is .xls . i have a xml file having extension .xls how to check the format because if i check extension its always come like .xls .
ASKER
Hi CEHJ can you please give me one example or some code snippet please it would be help me out more thanx in advance .i am attcahing a file here which is .xls file but format is xml i want to run a method when file is like .xls but with xml format . please let me know solution and some code snippet .
Demo.xls
Demo.xls
I don't have one i'm afraid. You might find one in the POI distribution
ASKER
please provide me some code snippet i m not getting any where ...
Are you sure that demo file is safe to upload to a public website?
Why not a quick PowerShell check?
$x = Get-Content Demo.xls -First 1
if($x.StartsWith("<?xml")) {
write-host("This is an XML file")
}else {
write-host("This is NOT an XML file")
}
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
https://poi.apache.org/apidocs/dev/org/apache/poi/poifs/filesystem/FileMagic.html#valueOf-java.io.File-