如何解析XLS文件? (已知语言:Python,Java,Lua) [英] How to parse a xls file? (Known languages : Python, Java, Lua)

查看:114
本文介绍了如何解析XLS文件? (已知语言:Python,Java,Lua)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试解析此xls文件:

I am trying to parse this xls file:

http://web.iyte.edu.tr/sks/xls/Agustos_Menu_2012.xls

橙色的地方有日期,并且爱那些日期,还有那一天的食物清单.所以,您能建议我一种解析日期和食物的方法吗?我尝试将xls转换为逗号分隔的值,但是某些字符正在更改,我不知道如何以有组织的方式将日期和食物放入数组或文件中,以便以后使用.谢谢.

Orange places have date and belove those dates there are food list of that day. So can you please suggest me a way to parse that to get dates and foods? I tried to convert that xls to comma seperated value but some characters are changing and i don't know how to get dates and foods into an array or a file in an organized way in order to use later.Thanks.

推荐答案

对于Java语言,请尝试使用grimholtz和lamber45提供的API-> sourceforge项目jexcelapi

For Java language try using API provided by grimholtz and lamber45 -> sourceforge project jexcelapi

该示例将基于不包含任何文件的文件.在B列第1行(标题)-4中 要先读取xls文件,请先导入库

The example will be based on the file which contains no. in col B in rows 1(header)-4 To read xls file first import libraries

import java.io.File;
import java.io.IOException;
import jxl.Cell;
import jxl.Sheet;
import jxl.read.biff.BiffException;
import jxl.Workbook;

其余代码将在main()方法中

Rest of the code will be in main() method

public class ReadXLS {
   public static void main(String[] args) throws IOException, BiffException {
   Workbook spreadsheet = Workbook.getWorkbook(new File("example.xls"));
   Sheet myspreadsheet = spreadsheet.getSheet(0); //numbers of spreadsheet starts from 0
   Cell mycell = myspreadsheet.getCell(1, 0);
   String header = mycell.getContents();
   System.out.println(header);
   for(int i=1; i<4; i++){
     mycell = myspreadsheet.getCell(1, i);
     System.out.println(mycell.getContents());
     }
   spreadsheet.close();

   }
}

这篇关于如何解析XLS文件? (已知语言:Python,Java,Lua)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆