我想在 Excel 工作表中写入时插入新行。
这是我的代码:
public static void addValuesInWorkbook(String pathAndFileName, String sheetName,
int rowNum, String valuesString,String delimeter) {
if(pathAndFileName.length() > 0 && sheetName.length() > 0 && rowNum >= 0 && valuesString.length() > 0 && delimeter.length() > 0)
{
String[] colValues= null;
if("|".equals(delimeter))
colValues = valuesString.split("\\|");
else
colValues = valuesString.split(delimeter);
int cellnum = 0;
FileInputStream fsIP;
try {
fsIP = new FileInputStream(new File(pathAndFileName));
//Read the spreadsheet that needs to be updated
if(rowNum > 0)
{
rowNum--; //As row indexing starts from 0 …Run Code Online (Sandbox Code Playgroud)