Olá,
minha chefe me pediu para fazer algo em C++, mas não achei nenhuma solução boa, achei então uma ótima biblioteca em JAVA e ela me disse que poderia usar em java e depois com JNI criar funções que funcionem no C, criei uma classe que se adequa as necessidades do projetos e depois fui pesquisar sobre JNI e é para funcionar tanto C p/ JAVA ou JAVA p/ C, mas só encontro exemplos de C p/ JAVA
alguem tem algum exemplo que mostre como tem que criar as classes, se tem que criar algum .h de criar esse link do JAVA p/ C?
aqui o código da minha classe que eu quero que funcione em C
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.jopendocument.dom.spreadsheet.Sheet;
import org.jopendocument.dom.spreadsheet.SpreadSheet;
public class ODSDecoder {
private Sheet sheet;
private String error;
public ODSDecoder() {
this.sheet = null;
}
public String inicializeDocument(String path) {
File file = new File(path);
try {
this.sheet = SpreadSheet.createFromFile(file).getSheet(0);
} catch (FileNotFoundException e) {
setError("Arquivo não encontrado.");
} catch (IOException e) {
setError("Arquivo corrompido ou erro de leitura.");
}
return "Arquivo lido com sucesso.";
}
public String getCelDataByHash(String cellName) {
return (String) this.sheet.getValueAt(cellName);
}
public String getCelDataByColumn(String columnName, int row) {
return (String) this.sheet.getValueAt(columnName + row);
}
public String getCelDataByIndex(int column, int row) {
return (String) this.sheet.getValueAt(column, row);
}
public void changeValueByHash(String cellName, String value) {
this.sheet.getCellAt(cellName).setValue(value);
}
public void changeValueByIndex(int column, int row, String value) {
this.sheet.getCellAt(column, row).setValue(value);
}
public void saveDocument(String path, String name) {
File outputFile = new File(path + name + ".ods");
try {
sheet.getSpreadSheet().saveAs(outputFile);
} catch (FileNotFoundException e) {
setError("Arquivo não encontrado.");
} catch (IOException e) {
setError("Arquivo corrompido ou erro de leitura.");
}
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
}
)