Easiest way to compare two Excel files in Java?

前端 未结 11 881
面向向阳花
面向向阳花 2021-02-02 14:23

I\'m writing a JUnit test for some code that produces an Excel file (which is binary). I have another Excel file that contains my expected output. What\'s the easiest way to com

11条回答
  •  逝去的感伤
    2021-02-02 14:28

    The easiest way I find is to use Tika. I use it like this:

    private void compareXlsx(File expected, File result) throws IOException, TikaException {
         Tika tika = new Tika();
         String expectedText = tika.parseToString(expected);
         String resultText = tika.parseToString(result);
         assertEquals(expectedText, resultText);
    }
    
    
    
        org.apache.tika
        tika-parsers
        1.13
        test
    
    

提交回复
热议问题