1 while reading downloaded xlsx file in Java

I am trying to read a xlsx file with particular row number which will be provided as parameter. I am getting NullPointerException if sheet.getRow(RowNum). I am able to read the xlsx file if i adjust column width and save it again manually. But that destroys my purpose of automation. I am able to read any other xlsx files which are created manually. Here is the sample code : public String

1,同时阅读Java下载的xlsx文件

我正在尝试读取具有特定行号的xlsx文件,该行号将作为参数提供。 如果sheet.getRow(RowNum),我得到NullPointerException。 我能够读取xlsx文件,如果我调整列宽并手动再次保存它。 但是这破坏了我的自动化目的。 我能够读取任何其他手动创建的xlsx文件。 以下是示例代码: public String readCouponCode(int getRowCount){ try { Registration reg=new Registration(); File inputFile = new File(this.Do

Convert jxl code to poi to read XLSX file

Recently I'm using jxl jar to read XLS excel file. But as I have to read XLSX excel file, I'm using poi jar. Here different classes are available while using poi jar. I have to read each cell of all available rows from sheet. While using jxl, I've buid below code... private static class SRAccess implements RowAccess { final Cell[] cells; SRAccess(Cell[] cells) {

将jxl代码转换为poi以读取XLSX文件

最近我使用jxl jar来读取XLS excel文件。 但是因为我必须阅读XLSX excel文件,所以我正在使用poi jar。 这里使用poi jar时可以使用不同的类。 我必须从表格中读取所有可用行的每个单元格。 在使用jxl时,我已经在代码下面创建了... private static class SRAccess implements RowAccess { final Cell[] cells; SRAccess(Cell[] cells) { this.cells = cells; } public String[] get() { S

to get columns from Excel files using Apache POI?

In order to do some statistical analysis I need to extract values in a column of an Excel sheet. I have been using the Apache POI package to read from Excel files, and it works fine when one needs to iterate over rows. However I couldn't find anything about getting columns neither in the API (link text) nor through google searching. As I need to get max and min values of different columns

使用Apache POI从Excel文件中获取列?

为了做一些统计分析,我需要在Excel工作表的一列中提取值。 我一直在使用Apache POI包来从Excel文件中读取数据,并且当需要遍历行时它可以正常工作。 不过,我找不到任何有关在API(链接文本)和谷歌搜索中都无法获取列的问题。 由于我需要获取不同列的最大值和最小值并使用这些值生成随机数,因此,如果不拾取单个列,唯一的选择是遍历行和列以获取值并逐一比较,时间一直很有效。 关于如何解决这个问题的任何想法? 谢

Portrait for phone, landscape for Tablet (Android

So I'm making an application for Android and I want to force Landscape orientation for tablets and Portrait orientation for phones. However, it seems as though I can only do an orientation lock from what I've seen which defeats the purpose of wanting two separate orientations for devices. Tablets: Landscape Phones: Portrait To put it more technical. I have a layout in "res/lay

手机肖像,平板电脑风景(Android

所以我正在为Android创建一个应用程序,并且我想强制使用平板电脑的横向方向和手机的纵向方向。 然而,看起来好像我只能从我所看到的方向锁定方向锁定,而这种方向锁定会破坏希望为设备分配两个方向的目的。 平板电脑:风景电话:肖像 把它放在技术上。 我在“res / layout-xlarge-land”中为平板电脑上的景观设计进行了布局,并在“res / layout”中拥有原始布局,我只是想明确使用平板电脑的layout-xlarge-land。 没有别的

JPA Criteria Builder: How to pass ArrayList to Oracle function?

I have an Oracle function that takes in a table of POINTS%ROWTYPE. I want to call this function from JPA using the CriteriaBuilder class, which has a function for database functions. When I try to build the query, it dies complaining that ArrayLists are not valid query parameters to the function. How do I pass in an ArrayList from JPA into an Oracle function? Oracle Function signature: CRE

JPA标准生成器:如何将ArrayList传递给Oracle函数?

我有一个Oracle函数,它包含一个POINTS%ROWTYPE表。 我想使用CriteriaBuilder类从JPA调用这个函数,它具有数据库函数的功能。 当我尝试构建查询时,它会死抱怨ArrayLists不是函数的有效查询参数。 我如何从JPA传入ArrayList到Oracle函数? Oracle函数签名: CREATE OR REPLACE FUNCTION LOCATION_CONTAINS ( LATITUDE_IN IN DOUBLE PRECISION, LONGITUDE_IN IN DOUBLE PRECISION, points IN types_pkg.point_array, numPo

How to tell Jackson to ignore a field during serialization if its value is null?

How can Jackson be configured to ignore a field value during serialization if that field's value is null. For example: public class SomeClass { // what jackson annotation causes jackson to skip over this value if it is null but will // serialize it otherwise private String someValue; } To suppress serializing properties with null values using Jackson >2.0, you can configure

如果杰克逊在序列化过程中忽略某个字段的值是否为空,该如何告诉他?

如果杰克逊可以配置为在序列化期间忽略字段值(如果该字段的值为空)。 例如: public class SomeClass { // what jackson annotation causes jackson to skip over this value if it is null but will // serialize it otherwise private String someValue; } 要使用Jackson> 2.0来抑制具有空值的序列化属性,可以直接配置ObjectMapper ,或者使用@JsonInclude注释: mapper.setSerializationInclusion(Incl

Jackson with JSON: Unrecognized field, not marked as ignorable

I need to convert a certain JSON string to a Java object. I am using Jackson for JSON handling. I have no control over the input JSON (I read from a web service). This is my input JSON: {"wrapper":[{"id":"13","name":"Fred"}]} Here is a simplified use case: private void tryReading() { String jsonStr = "{"wrapper":[{"id":"13","name":"Fred"}]}"; ObjectMapper mapper = new ObjectMapper()

杰克逊与JSON:无法识别的字段,未标记为可忽略

我需要将某个JSON字符串转换为Java对象。 我使用Jackson进行JSON处理。 我无法控制输入的JSON(我从Web服务中读取)。 这是我的输入JSON: {"wrapper":[{"id":"13","name":"Fred"}]} 这是一个简化的用例: private void tryReading() { String jsonStr = "{"wrapper":[{"id":"13","name":"Fred"}]}"; ObjectMapper mapper = new ObjectMapper(); Wrapper wrapper = null; try { wrapper = mapper

How to use Jackson to validate duplicated properties?

I'm using Jackson JSON library to convert some JSON objects to POJO classes. The problem is, when I use JSON Objects with duplicated properties like: { "name":"xiaopang", "email":"xiaopang1@123.com", "email":"xiaopang2@123.com" } Jackson report the last email pair "email":"xiaopang2@123.com" and then parse the object. I've learned from Does JSON syntax allow

如何使用杰克逊来验证重复的属性?

我正在使用Jackson JSON库将一些JSON对象转换为POJO类。 问题是,当我使用具有重复属性的JSON对象时: { "name":"xiaopang", "email":"xiaopang1@123.com", "email":"xiaopang2@123.com" } 杰克逊报告最后一封电子邮件"email":"xiaopang2@123.com" ,然后解析该对象。 我从中学到了JSON语法是否允许在对象中使用重复键? 那么在反序列化具有重复属性的JSON对象时会发生什么情况取决于库实现,它

Convert JSON object with duplicate keys to JSON array

I have a JSON string that I get from a database which contains repeated keys. I want to remove the repeated keys by combining their values into an array. For example Input { "a":"b", "c":"d", "c":"e", "f":"g" } Output { "a":"b", "c":["d","e"], "f":"g" } The actual data is a large file that may be nested. I will not know ahead of time what or how many pairs there are. I need to use Jav

将具有重复键的JSON对象转换为JSON数组

我有一个JSON字符串,我从包含重复键的数据库中获得。 我想通过将它们的值组合到一个数组中来移除重复的键。 例如 输入 { "a":"b", "c":"d", "c":"e", "f":"g" } 产量 { "a":"b", "c":["d","e"], "f":"g" } 实际的数据是一个可能嵌套的大文件。 我不会提前知道什么或有多少对。 我需要为此使用Java。 org.json抛出一个异常,因为重复键,gson可以解析字符串,但每个重复的键都会覆盖最后一个键。 我需要保留所有的

Do JSON keys need to be unique?

This question already has an answer here: Does JSON syntax allow duplicate keys in an object? 11 answers There is no "error" if you use more than one key with the same name, but in JSON, the last key with the same name is the one that is going to be used. In your case, the key "name" would be better to contain an array as it's value, instead of having a number of ke

JSON密钥是否必须是唯一的?

这个问题在这里已经有了答案: JSON语法是否允许在对象中使用重复键? 11个答案 如果您使用具有相同名称的多个键,则不会出现“错误”,但在JSON中,具有相同名称的最后一个键是将要使用的键。 在你的情况下,关键的“名称”会更好地包含一个数组,因为它的值,而不是有多个键“名称”。 同一个对象或“事物”具有两个名称或两个相同的冲突属性没有多大意义。 例如: { "name" : [ "JOHN", "JACK", "...", ... ] } 从RFC 4