我刚才有一个关于如何使用Apache的XSSF格式读取xlsx文件的快速问题.
现在我的代码看起来像这样:
InputStream fs = new FileInputStream(filename); // (1)
XSSFWorkbook wb = new XSSFWorkbook(fs); // (2)
XSSFSheet sheet = wb.getSheetAt(0); // (3)
Run Code Online (Sandbox Code Playgroud)
......导入了所有相关的东西.我的问题是,当我点击运行时,它会陷入第(2)行,几乎是无限循环.filename只是一个字符串.
如果有人能给我一些关于如何解决这个问题的示例代码,我将非常感激.我现在想要的只是从xlsx文件中读取单个单元格; 我使用HSSF用于xls文件并且没有问题.
谢谢你的帮助,安德鲁
我使用了构建了一个新的工作簿WorkbookFactory.create(new File("path/to/xlsx")).但是,当我尝试在启动应用程序后在Excel中编辑文件时,我收到一条错误消息,指出该文件正在使用中.我是否必须释放文件,如果是,如何?(我Workbook.close()在api文档中找不到任何内容)或者我必须在其他地方查找?
我不知道在哪里可以看; 应用程序不会导致csv和excel文件的这些问题我只是调用转换器(xls => csv),这是唯一的区别.
(我正在使用POI 3.8)
我需要关闭Marionette/GeckoDriver日志记录; 有没有办法做到这一点?我一直在寻找,但我没有得到正确的答案.INFO日志是:
1484653905833 geckodriver INFO Listening on 127.0.0.1:15106
Jan 17, 2017 5:21:46 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
1484653906715 mozprofile::profile INFO Using profile path C:\Users\vtiger\AppData\Local\Temp\3\rust_mozprofile.7d2LEwDKoE8J
1484653906720 geckodriver::marionette INFO Starting browser C:\Program Files\Mozilla Firefox\firefox.exe
1484653906731 geckodriver::marionette INFO Connecting to Marionette on localhost:58602
1484653908388 addons.manager DEBUG Application has been upgraded
1484653908843 addons.manager DEBUG Loaded provider scope for resource://gre/modules/addons/XPIProvider.jsm: ["XPIProvider"]
1484653908846 addons.manager DEBUG Loaded provider scope for resource://gre/modules/LightweightThemeManager.jsm: ["LightweightThemeManager"]
1484653908852 addons.manager DEBUG Loaded …Run Code Online (Sandbox Code Playgroud) 我在这里找不到确切的答案。如果我错了,请纠正我。
是否有令人信服的理由要使用VARBINARY预期中值大小为40KB且异常稀疏的异常值可以达到2MB(当有人上传扫描时)的文档文件?
根据Technet:
[
FILESTREAM在以下情况下适当]:正在存储的对象平均大于1 MB。
...在我看来,这与事实相去甚远。
文件表本身将很小。绝对限制为2000个文件。批量下载将限制为10个文件。
在这种情况下,有可能是在所有没有区别FILESTREAM和VARBINARY(MAX)。选择文件时,除了文件大小和批量下载外,还有其他因素要考虑吗?
我想在MediaWiki网站上使用其文件描述页面中的描述作为语法中的标题显示图像[[File:imagename.png|frame|caption]].为了澄清,我不是要链接到图像的描述页面.
我已经阅读了有关在这个问题上查询API的一些内容,但是我很难看到如何在源代码中显示查询结果(是它iiprop=comment或者rvprop=content其他东西).
我试图扩展EnumSet到Comparable在Eclipse中实现.但是,从一开始我就充满了错误.这是我开始的:
package sets;
import java.util.EnumSet;
enum Suits{
SPADE, DIAMOND, CLUB, HEART;
}
class ExtendedEnumSet extends EnumSet<Suits> implements Comparable<Suits> {
}
Run Code Online (Sandbox Code Playgroud)
它立即通知我:Implicit super constructor EnumSet<Suits>() is undefined for default constructor. Must define an explicit constructor.所以,我按照快速修复,它添加了以下构造函数:
ExtendedEnumSet(Class<Suits> finalArg0, Enum[] finalArg1) {
super(finalArg0, finalArg1);
// TODO Auto-generated constructor stub
}
Run Code Online (Sandbox Code Playgroud)
......然后它通知我:The constructor EnumSet<Suits>(Class<E>, Enum[]) is not visible.我已经尝试更改此类和此构造函数的访问修饰符无济于事.
下一个问题是当我决定继续并修复Eclipse报告的下一个错误时:The type ExtendedEnumSet must implement the inherited abstract method AbstractCollection<Suits>.iterator().当然,这只是冰山一角.我再次使用快速修复(add unimplemented methods)并添加以下内容: …
我有一个函数在a上执行一些流操作(特别是一个过滤器)List.
public List<String> getAndFilterNames(List<Person> people, Predicate<Person> nameFilter){
List<String> allNames = people.stream()
.map(person -> person.getName())
.filter(nameFilter)
.collect(Collectors.toList());
return allNames;
}
Run Code Online (Sandbox Code Playgroud)
我希望能够通过中间流操作(filter,distinct等),并有我的功能运行的终端操作之前执行该操作.就像是:
public List<String> getAndProcessNames(List<Person> people, <intermediate stream operation>){
List<String> allNames = people.stream()
.map(person -> person.getName())
// perform <intermediate stream operation> here
.collect(Collectors.toList());
return allNames;
}
Run Code Online (Sandbox Code Playgroud)
虽然,根据我目前的经验水平,似乎是不可能的.一些中间操作有一个参数(比如filter),有些没有(比如distinct),所以我不能设置一个能处理所有情况的参数类型...我想我可以创建一些签名,但是Function和Supplier.
即便如此,该功能界面与参数的功能需要变化...... filter需要Predicate,map需要Function,并从我的理解,是没有办法来表示一个通用的功能接口.那是对的吗?它们都没有真正的公共类或接口.
那么,到底,看来我最好的选择是公正map和collect,然后运行所需的我流操作的情况下,逐案的基础,如:
public List<String> getNames(List<Person> people){
List<String> allNames = …Run Code Online (Sandbox Code Playgroud) 我有以下代码:
struct Stuff {
thing: i8
}
fn main(){
let theStuff = Stuff { thing: 1 };
println!("{}", theStuff.thing * 1.5);
}
Run Code Online (Sandbox Code Playgroud)
我在编译时得到以下内容:
error[E0277]: the trait bound `i8: std::ops::Mul<{float}>` is not satisfied
--> IntFloatMultiply.rs:7:32
|
7 | println!("{}", theStuff.thing * 1.5);
| ^ no implementation for `i8 * {float}`
|
= help: the trait `std::ops::Mul<{float}>` is not implemented for `i8`
Run Code Online (Sandbox Code Playgroud)
我已经阅读了其他一些帖子,其中包括一些非常好的内容(包括/sf/answers/3118672511/).如果我没有具体的答案,我不关心技术细节,什么或为什么.如何编译此代码以显示浮点结果?
apache-poi ×2
java ×2
apache ×1
caption ×1
constructor ×1
enumset ×1
excel ×1
extends ×1
file-io ×1
filestream ×1
gecko ×1
geckodriver ×1
image ×1
java-8 ×1
java-stream ×1
mediawiki ×1
methods ×1
rust ×1
selenium ×1
sql-server ×1
subclass ×1
wikipedia ×1
xssf ×1