如何将变量放在import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author
*/
public class FileCatch8 {
public static void main(String args[]) {
List<String> fileNames = new ArrayList<>();
try {
DirectoryStream<Path> directoryStream = Files.newDirectoryStream
(Paths.get("files"));
int fileCounter = 0;
WordCount wordCnt = new WordCount();
for (Path path : directoryStream) {
System.out.println(path.getFileName());
fileCounter++;
fileNames.add(path.getFileName().toString());
System.out.println("word length: " + fileCounter + " ==> " +
wordCnt.count(path.getFileName().toString()));
}
} catch(IOException ex){
}
System.out.println("Count: "+fileNames.size()+ " files");
}
}
?
.setFormula
我的问题是变量文本是一个名称,我需要它作为条件在引号中。如果没有,公式将不起作用,并且需要设置activeSheet.getRange(125,2).setFormula("=SOMME.SI($A$1:$A$40;"+text+";B1:B40)*B124");
manualy
有人可以帮忙吗?
答案 0 :(得分:1)
你可以使用单引号
activeSheet.getRange(125,2).setFormula("=SOMME.SI($A$1:$A$40;'"+text+"';B1:B40)*B124");
甚至更好地使用string template literals(注意反引号)
activeSheet.getRange(125,2).setFormula(`=SOMME.SI($A$1:$A$40;"${text}";B1:B40)*B124`);