Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel file corrupt when copied from src to target in Eclipse IDE

Tags:

I have a strange issue with eclipse. When I put a .xls file in the src/test/resources path it is copied by eclipse to the target path.

However, the file in the target path is not the same anymore. I cannot open it in MS Excel anymore and when I compare the two files, I see some binary differences. How can this happen?

PS: my eclipse environment is generated with maven.

like image 478
bertolami Avatar asked Apr 05 '12 07:04

bertolami


2 Answers

Thanks to the above answers we found out how to deal with the problem:

    <plugin>       <artifactId>maven-resources-plugin</artifactId>       <version>2.5</version>       <configuration>         <encoding>UTF-8</encoding>         <nonFilteredFileExtensions>           <nonFilteredFileExtension>xls</nonFilteredFileExtension>         </nonFilteredFileExtensions>       </configuration>     </plugin> 
like image 155
bertolami Avatar answered Oct 02 '22 15:10

bertolami


I had the same issue, and it was cause by the Maven resources plugin which filtered and altered my Excel files.

To prevent this to happen, add something like this (see the Maven doc) :

<build>                       <resources>            <resource>                <filtering>true</filtering>                <directory>src/test/resources</directory>                <excludes>                    <exclude>**/*.xls</exclude>                </excludes>          </resource> ... 

UPDATE : Copy in resources, but don't filter

<resources>       <resource>         <directory>src/test/resources</directory>         <filtering>true</filtering>         <excludes>           <exclude>**/*.xls</exclude>         </excludes>       </resource>       <resource>         <directory>src/test/resources</directory>         <filtering>false</filtering>         <includes>           <include>**/*.xls</include>         </includes>       </resource>       ...     </resources> 
like image 26
ndeverge Avatar answered Oct 02 '22 13:10

ndeverge