我有一个.xlsx格式的Excel文件.我通过合并单元格来形成各种列来存储数据.我正在通过Java Web应用程序读取Excel文件并将其数据保存到数据库(MySQL).但是当我从合并的单元格中读取时,我得到的是空值以及存储在列和标题中的内容.我正在使用Apache POI.我的代码是:
public static void excelToDBLogIN() {
FileInputStream file = null;
Boolean flag = true;
ArrayList<String> rows = new ArrayList<String>();
try {
// here uploadFolder contains the path to the Login 3.xlsx file
file = new FileInputStream(new File(uploadFolder + "Login 3.xlsx"));
//Create Workbook instance holding reference to .xlsx file
XSSFWorkbook workbook = new XSSFWorkbook(file);
//Get first/desired sheet from the workbook
XSSFSheet sheet = workbook.getSheetAt(0);
//Iterate through each rows one by one
Iterator<Row> rowIterator = sheet.iterator();
while (rowIterator.hasNext()) {
Row …Run Code Online (Sandbox Code Playgroud)