import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
public class ExcelUtils {
public static void deleteFirstColumn(String filePath) throws Exception {
Workbook workbook = WorkbookFactory.create(new File(filePath));
Sheet sheet = workbook.getSheetAt(0); // 获取第一个 Sheet
for (Row row : sheet) {
row.removeCell(row.getCell(0)); // 删除第一列单元格
row.shiftCellsLeft(1, row.getLastCellNum() - 1, 1); // 左移单元格
}
FileOutputStream fileOutputStream = new FileOutputStream(filePath);
workbook.write(fileOutputStream);
fileOutputStream.close();
workbook.close();
}
}