miachm / SODS

A simple Java library for handle ODS (Open Document Spreadsheet, compatible with Excel and Libreoffice)
The Unlicense
74 stars 30 forks source link

The character type cannot be output. #25

Closed tarian1995 closed 2 years ago

tarian1995 commented 4 years ago

The character type cannot be output. e.g.

public static void main(String[] args) throws Exception{
        SpreadSheet spreadSheet = new SpreadSheet();
        String projectPath = System.getProperty("user.dir");
        int rows = 3;
        int columns = 3;
        Sheet sheet = new Sheet("A", rows, columns);
        Range range = sheet.getRange(1, 1);
        range.setValue("ABC");
        spreadSheet.appendSheet(sheet);
        File file = new File(projectPath + "/src/main/resources/file/test2.ods");
        if (!file.exists()) {
            file.createNewFile();
        }
        spreadSheet.save(file);
    }

Is the string type not supported?

miachm commented 4 years ago

I am sorry, I don't know how to reproduce this issue.

May I have the ods file?

tarian1995 commented 4 years ago

My ods file is generated directly through Java IO. I changed the number to characters based on your demo and found that the output file was empty. Yours DEMO

 public static void main(String args[]){
        try {
            int rows = 3;
            int columns = 3;
            Sheet sheet = new Sheet("A", rows, columns);

            sheet.getDataRange().setValues("A","B","C","A","B","C","A","B","C");

            // Set the underline style in the (3,3) cell
            sheet.getRange(2,2).setFontUnderline(true);

            // Set a bold font to the first 2x2 grid
            sheet.getRange(0,0,2,2).setFontBold(true);

            SpreadSheet spread = new SpreadSheet();
            spread.appendSheet(sheet);
            spread.save(new File("Out.ods"));
        } catch (IOException e){
            e.printStackTrace();
        }
    }

Maybe I'm using it in a way that's wrong?

Thank you very much for your answer. Greetings

miachm commented 4 years ago

It works great for me... Which version are you using?

qiancj commented 4 years ago

This problem[The character type cannot be output. #25] occurs when you open it with Excel

ghost commented 3 years ago

This problem[The character type cannot be output. #25] occurs when you open it with Excel

For excel, you would better to use Apache POI.

miachm commented 2 years ago

It seems this should be solved with the new 1.5.1