Sorry to say this but I cannot reproduce the problem. This morning, I wrote
the following very simple piece of code to use as a test;

import java.io.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

/**
 *
 * @author Mark B
 */
public class MergeTest {
    
    public MergeTest(String filename) throws IOException {
        File file = null;
        FileOutputStream fos = null;
        Workbook workbook = null;
        Sheet sheet = null;
        Row row = null;
        Cell cell = null;
        CellRangeAddress mergedCells = null;
        try {
            if(filename.endsWith(".xlsx")) {
                workbook = new XSSFWorkbook();
            }
            else {
                workbook = new HSSFWorkbook();
            }
            sheet = workbook.createSheet("Merge Test");
            
            // Firstly, merge together cells A1 and C1
            mergedCells = new CellRangeAddress(0, 0, 0, 2);
            sheet.addMergedRegion(mergedCells);
            row = sheet.createRow(0);
            cell = row.createCell(0);
            cell.setCellValue("A1");
            
            // Now, merge together cell in a single column, cells D1 to D3
            mergedCells = new CellRangeAddress(0, 2, 3, 3);
            sheet.addMergedRegion(mergedCells);
            cell = row.createCell(3);
            cell.setCellValue("D1");
            
            // Finally, merge toghet cells in a square block, say F1 to H5
            mergedCells = new CellRangeAddress(0, 4, 5, 7);
            sheet.addMergedRegion(mergedCells);
            cell = row.createCell(5);
            cell.setCellValue("F1");
            
            // Now save the workbook away.
            file = new File(filename);
            fos = new FileOutputStream(file);
            workbook.write(fos);
        }
        finally {
            if(fos != null) {
                fos.close();
                fos = null;
            }
        }
    }
    
    public static void main(String[] args) {
        try {
            if(args.length == 1) {
                new MergeTest(args[0]);
            }
        }
        catch(Exception ex) {
            System.out.println("Caught a: " + ex.getClass().getName());
            System.out.println("Message: " + ex.getMessage());
            System.out.println("Stacktrace follows:.....");
            ex.printStackTrace(System.out);
        }
    }
}

and could not reproduce the error you reported.

Can you please create a similarly simple test case that does demonstrate the
problem and post that piece of code to the list? If you do so then we will
be able to conduct further investigations.
Yours

Mark B

PS The code was compiled against version 3.8. Which version are you using?



--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Excel-error-Excel-found-unreadable-content-with-POI-3-7-and-excel-2007-tp3386164p5711025.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to