'How can i shift all rows without giving exception?
I have a workbook with 4 sheets in it. I cloned the 4th sheet. I'm trying to shift all the data from the new cloned sheet down by 1 row. But when i try the shiftRow in one of my methods, it gives a FormulaParseException. Any help appreciated.
public class SanityChecker extends BaseCostSheetCmd {
String fileName = "C:/Users/.../.xlsx";
File file = new File(fileName);
String vendorFile = "C:/Users/.../.xlsx";
public void initWB() throws IOException {
FileInputStream is = new FileInputStream(fileName);
XSSFWorkbook wb = (XSSFWorkbook) XSSFWorkbookFactory.create(is);
XSSFSheet out = wb.cloneSheet(3, "sanity check");
FileOutputStream fs = new FileOutputStream(fileName);
is.close();
wb.write(fs);
fs.close();
wb.close();
}
public void addRow(File file, int amount, int currentRow) throws Exception {
FileInputStream is = new FileInputStream(file);
XSSFWorkbook workbook = new XSSFWorkbook(is);
XSSFSheet sheet = workbook.getSheetAt(4);
sheet.shiftRows(currentRow, sheet.getLastRowNum() + 1, amount, true,true);
is.close();
FileOutputStream out = new FileOutputStream(file);
workbook.write(out);
out.close();
workbook.close();
}
@Override
public void process(Matcher m) throws Exception {
// TODO start here
initWB();
addRow(file, 1, 0);
logln("hello world");
}
Exception:
org.apache.poi.ss.formula.FormulaParseException: Unused input [[[#All],[TRIMMED CAT NUM]:[DISTRIBUTOR MULTIPLIER]]] after attempting to parse the formula [[1]!018128_1634058909268[[#All],[TRIMMED CAT NUM]:[DISTRIBUTOR MULTIPLIER]]]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
