Tag: java

把我的双打格子变成了双打

我正在从每个指定的列中的每一行的Excel文件,使用row.getCell(); 我想这个数据在一个ArrayList中。 我如何去转换的细胞srs的内容和ArrayList。 for(Row row : sheet){ if(row.getRowNum() == 0) continue; Cell Rk = row.getCell(2); Cell seed = row.getCell(1); Cell srs = row.getCell(7); System.out.println(srs); This is what it prints 0.974 0.588 0.213 ect.

根据电子表格select页面上的值 – Java – Selenium Webdriver

我需要阅读电子表格的值,并在页面上select相同的值。 使用下面的代码,我可以读取电子表格的第一列和第二列,并填写页面上的字段,但是我无法读取第三列并selectSelect页面的值。 如何使用Java和Selenium? package testeplanilha; import java.io.File; import java.io.IOException; import jxl.Sheet; import jxl.Workbook; import jxl.read.biff.BiffException; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.ie.InternetExplorerDriver; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.support.ui.Select; public class testePlanilha { public static void main(String[] args) throws BiffException, IOException { String nome = ""; String sobrenome= ""; String tipo = ""; WebDriver driver […]

按照单张页面单击一个单选button的值 – Java – Selenium Webdriver

如何在工作表上读取一个值,并使用java和Selenium Webdriver在页面上的单选button中select相同的值? Workbook workbook = Workbook.getWorkbook(new File("C:/plan.xls")); Sheet sheet = workbook.getSheet(0); int rowCount = sheet.getRows(); for(int i = 0; i < rowCount; i++){ String nome2 = sheet.getCell(0, i).getContents(); String Sobrenome2 = sheet.getCell(1, i).getContents(); String tipo2 = sheet.getCell(2, i).getContents(); String aparelho = sheet.getCell(3, i).getContents(); driver.findElement(By.id("nome")).sendKeys(nome2); driver.findElement(By.id("sobrenome")).sendKeys(Sobrenome2); Select verificaOpt = new Select(driver.findElement(By.id("select"))); // as before String titleCaseType […]

Java POI中的InvalidFormatException

这是我得到的exception: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13] 我试图打开的文件是一个.xls文件,我寻找可能的解决scheme,我发现这个和这个 ,但我已经正确地做这个,所以这不是问题。 我的代码: InputStream file = new FileInputStream(new File(path)); org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(file); org.apache.poi.ss.usermodel.Sheet sheet = workbook.getSheetAt(sheetNumber); sheetNumber是一个int(在我的软件中它总是0),path是正确的,在发布之前我testing了这两次,以确保我没有失败。 抛出exception的行是: org.apache.poi.ss.usermodel.Workbook workbook = WorkbookFactory.create(file); (如果你想了解更多关于代码的细节,可以在这里find全class) 有谁知道我可以在哪里失败? 谢谢你们。

使用Apache POI及其名称获取Excel公式的内容

问题是我如何才能通过名字获得一个公式的内容。 在Excel中,您可以使用公式名称对表进行分组。 我想用Apache POI来获取这样一个名为table的公式的内容。 所以即使表扩展,我也总是得到最新的数据。 因为名字不会改变。 我做了一些编码,但到目前为止,我只能获得一张表的所有内容,而不是公式名的表。 我的代码在下面,谢谢。 package getTablesPOI; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.Iterator; public class readExcel { // Creates a new instance of POIExcelReader public readExcel() { } /** * The main […]

而将Excel转换为.csv文件,我不能够转换date,并将其保存在CSV文件?

我正在使用Apache POI 3.6,我想从Excel中读取数据,并将Excel数据转换为.CVS文件。 我的Excel数据将以这种格式 第一列将是:date(8/6/2009) 第二栏将是:时间(上午12:00:01) 第三列将是:值1(30) 第四列将是:值2(400.99)。 我需要以这种格式(8-6-2009)转换这些数据,并将其存储在CVS文件中。错误:我可以将数据存储在csv文件中,但不能将其中的date和时间转换。 它在date列中获取41426一些值,在时间列我得到这个3456.0。 我没有得到如何转换这上面:请任何人帮我出.. 🙁 我的代码在这里: import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.Iterator; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.DateUtil; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class Excel { static void xlsx(File inputFile, File outputFile) { // For storing data into CSV files StringBuffer data = new StringBuffer(); try […]

一次只读一个“行”的Java制表符分隔的文件

我已经编写代码一次读取一行(行)制表符分隔的文件。 我通过将其保存为制表符分隔的文本文件,从Excel电子表格中创build了他的文件。 电子表格中的每一行都有39列,这意味着38个选项卡。 这样做的目的是能够在XML标签中将39位数据中的每一位(包括空位)进行包装。 但是,这个代码a。 一次一行地打印电子表格中的每一条数据,我在尝试访问特定的数据项时遇到了困难,这是必不可less的。 例如,第一列是用户标识,第十二列是主要地址行1,第36列是用户标识。 但是,如果我改变下面的代码得到(55)我得到一个IndexOutOfBoundsexception。 如果我询问第一个数据,得到(0),程序列出整个文件中的每一个数据。 boolean resultFlag = false; try { theScanner = new Scanner(new FileReader("C:\\WMS\\GGBTS_Patron_Data_20160317_V1-0.txt")); while (theScanner.hasNextLine()) { patronRow = theScanner.next(); itemArray = new ArrayList(Arrays.asList(patronRow.split("\t"))); for(int i=0; i<itemArray.size(); i++) { System.out.println(" –>"+itemArray.get(i)); } } resultFlag = true; } 在进入下一个逻辑行之前,我需要做些什么才能获得单行的39个元素,并能够通过索引号引用它们? 我不知道Excel是否将制表符分隔的文件保存为\ n \ r之类的。 请帮助。 我在这里受到一些阻碍,因为虽然我是一个程序员多年,但在目前的情况下,我是一个小型图书馆的学术参考图书馆员,没有办法获得IT支持。 无论如何,我知道编程比我们的两个IT人员更好,他们处理操作,而不是编码。 谢谢。 肯

如何使用Tika或任何其他库从PDF文件中提取数据并以CSV / Excel格式存储

我想提取PDF文件中存在的数据,并以CSV / Excel表单的格式显示。我知道这可以在java.But中使用Tika库来完成,我确实find了如何提取数据作为简单的文本,但我想知道如何将其存储在Excel表格中。 如果有人早些时候做过这种types的工作,那么请帮助我。

我们可以使用java更新密码保护excel表的行和列吗?

NPOIFSFileSystem fs = new NPOIFSFileSystem(new File("C://Users//RK5026051//Downloads//500_Lanes.xls")); EncryptionInfo info = new EncryptionInfo(fs); Decryptor d = Decryptor.getInstance(info); if (d.verifyPassword("manh.com")) { HSSFWorkbook wb = new HSSFWorkbook(d.getDataStream(fs)); } else { System.out.println("wrong password"); } // TODO Auto-generated method stub } 错误 – Exception in thread "main" java.io.FileNotFoundException: no such entry: "EncryptionInfo", had: [_VBA_PROJECT_CUR, SummaryInformation, DocumentSummaryInformation, Workbook] at org.apache.poi.poifs.filesystem.DirectoryNode.getEntry(DirectoryNode.java:370) at org.apache.poi.poifs.filesystem.DirectoryNode.createDocumentInputStream(DirectoryNode.java:177) […]

写入excel文件时会丢失一些数据。 Java的

我创buildXLSX文件并添加到单元格的一些值,它写道,一切正常,但是当我读回文件或只是打开文件。 我没有看到所有的数据。 File myfile = new File("hello.xlsx"); Workbook workBook = new XSSFWorkbook(); Sheet sheet = workBook.createSheet("sheet"); String[] tokens= {"A1", "B5", "C7", "J1", "K15", "Z20"}; for (String tok: tokens) { CellReference ref = new CellReference(tok); Row row = sheet.createRow(ref.getRow()); Cell cell = row.createCell((short) ref.getCol()); cell.setCellValue("blabla"); System.out.println(ref); } workBook.write(new FileOutputStream(myfile)); workBook.close(); System.out.println(); FileInputStream fileInputStream = new FileInputStream(myfile); […]