/*根据属性组把属性和属性值写入XLS*/
public void writeArrtibute(Environment env, Iterator it,int articleid,
jxl.write.WritableWorkbook wwb) throws Exception {
try {
jxl.write.WritableSheet ws = wwb.createSheet("产品属性", 4);
Article article = env.getArticle(articleid);
// Iterator it = getAttrGroupByArticleId(env, articleid).iterator();
int row = 0;
while (it.hasNext()) {
AttrGroup gruop = (AttrGroup) it.next();
for (Iterator it2 = gruop.getAttrDics().values().iterator();
it2.hasNext(); ) {
int coll = 0;
AttrDic attrDic = (AttrDic) it2.next();
int AttrDicType = attrDic.getAttrDicID();
if (AttrDicType != 6) {
jxl.write.Label label0 = new jxl.write.Label(coll++, row,
String.valueOf(articleid));
ws.addCell(label0);
jxl.write.Label label1 = new jxl.write.Label(coll++, row,
attrDic.getOuterName());
ws.addCell(label1);
}
ExtendedField attrField = article.getField(attrDic.getAttrDicID());
Attribute attrb = null;
LongAttribute lattr = null;
if (attrField != null) {
if (AttrDicType != 6) {
attrb = (Attribute) attrField.getValue();
}
else {
//lattr = (LongAttribute) attrField.getValue();
}
}
String sattrb = "";
if (attrb != null) {
switch (AttrDicType) {
case 1:
int intValue = attrb.getIntValue();
sattrb = String.valueOf(intValue);
break;
case 2:
double dbValue = attrb.getDblValue();
sattrb = String.valueOf(dbValue);
break;
case 3:
sattrb = attrb.getStrValue();
break;
}
if (attrDic.getUnit() != null) {
sattrb += attrDic.getUnit();
}
}
// if (lattr != null) {
// sattrb = lattr.getFilePath();
// }
System.out.print("**************" + "<br>");
if (AttrDicType != 6) {
jxl.write.Label label2 = new jxl.write.Label(coll++, row, sattrb);
ws.addCell(label2);
row++;
}
else {
//jxl.write.Label labelCc33_ =new jxl.write.Label(coll_++,row_,sattrb);
//ws3.addCell(labelCc33_);
}
}
}
}
catch (Exception e) {
throw new Exception(
"ExportAttrbuteData writeArrtibute(env,articleid,wwb) Error! " +
e.getMessage());
}
}
5 个解决方案
#1
while(数据导完标志=false)
{
try
{
循环导出数据...,直至完.
设置数据导完标志 = true;
}
catch(导数据当中出现小异常)
{
跳过,继续导.
}
}
{
try
{
循环导出数据...,直至完.
设置数据导完标志 = true;
}
catch(导数据当中出现小异常)
{
跳过,继续导.
}
}
#2
但是我怎样在catch里再继续进行导出操作呢?Iterator又怎样处理呢?帮帮忙啦!
#3
没必要在catch里继续导,直接跳过,让try继续导下一数据
#4
你看这样可以吗?是这样吗?
Iterator it = mapp.values().iterator();
while(flag==ture){
try{
while(it.hasNext()){
Integer I = (Integer) it.next();
导出一条记录操作;
}
//数据导完
flag=false;
}catch(Exception e){
continue;
}
} //end while(flag)
Iterator it = mapp.values().iterator();
while(flag==ture){
try{
while(it.hasNext()){
Integer I = (Integer) it.next();
导出一条记录操作;
}
//数据导完
flag=false;
}catch(Exception e){
continue;
}
} //end while(flag)
#5
可以
#1
while(数据导完标志=false)
{
try
{
循环导出数据...,直至完.
设置数据导完标志 = true;
}
catch(导数据当中出现小异常)
{
跳过,继续导.
}
}
{
try
{
循环导出数据...,直至完.
设置数据导完标志 = true;
}
catch(导数据当中出现小异常)
{
跳过,继续导.
}
}
#2
但是我怎样在catch里再继续进行导出操作呢?Iterator又怎样处理呢?帮帮忙啦!
#3
没必要在catch里继续导,直接跳过,让try继续导下一数据
#4
你看这样可以吗?是这样吗?
Iterator it = mapp.values().iterator();
while(flag==ture){
try{
while(it.hasNext()){
Integer I = (Integer) it.next();
导出一条记录操作;
}
//数据导完
flag=false;
}catch(Exception e){
continue;
}
} //end while(flag)
Iterator it = mapp.values().iterator();
while(flag==ture){
try{
while(it.hasNext()){
Integer I = (Integer) it.next();
导出一条记录操作;
}
//数据导完
flag=false;
}catch(Exception e){
continue;
}
} //end while(flag)
#5
可以