我们如何得到background color一个XSSFCell。我尝试使用XSSFCellStyle但没有运气。
FileInputStream fis = new FileInputStream(fileName);
XSSFWorkbook book = new XSSFWorkbook(fis);
XSSFSheet sheet = book.getSheetAt(0);
XSSFRow row = sheet.getRow(0);
System.out.println(row.getCell(0).getCellStyle().getFillForegroundColor());
Run Code Online (Sandbox Code Playgroud)
使用这些步骤,我无法获得Short类型的背景色表示。
我正在尝试创建一个模板函数,它具有两个基于模板参数的不同实现.第一个是针对I/O操纵器的,第二个针对任何一般情况.
template <typename T>
typename std::enable_if<
std::is_same<decltype(std::setw), T>::value>::type
foo(T& t){
cout << "enabled" << std::endl;
}
template <typename T>
void foo(T& t){
cout << "Normal" << std::endl;
}
template <typename... Ts>
void foohelper(Ts... t){
foo(t...);
}
int main(){
foohelper(std::setprecision(3)); // It should print enabled, but printing Normal
}
Run Code Online (Sandbox Code Playgroud)
目前它没有做我想要实现的.我该如何解决?
我正在尝试调整在定义的自定义类上定义的向量
class Product{
private:
Product *next;
int pid;
public:
Product(int _pid): pid(_pid){}
};
int main(){
vector<Product> v;
v.resize(1, Product(1));
v[0] = Product(1);
cout<< v.size() << endl;
v.resize(2, Product(2));
}
Run Code Online (Sandbox Code Playgroud)
当我第二次尝试调整它时,我的代码失败了,我已经查看了其他答案,但我无法理解它背后的想法.
我有一个要求,我需要调整向量的大小.
有人可以解释一下吗?有什么解决方法吗?