这是我的一段代码我遇到了麻烦
package com.my.dao;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import com.my.util.HibernateUtil;
/**
* @author Ilias
*
*/
public class DepartementImplDB implements DepartementDao {
/**
* @see com.my.dao.DepartementDao#addDepartement(com.my.dao.Departement)
*/
@Override
public int addDepartement(Departement D) {
// TODO Auto-generated method stub
Session session = HibernateUtil.getInstance().getSessionFactory().getCurrentSession();
session.beginTransaction();System.out.println("********");
session.save(D);System.out.println("departement implement metier");
session.getTransaction().commit();
D=this.getDepartementByNom(D.getNomDepartement());
return D.getId();
}
/**
* @see com.my.dao.DepartementDao#getDepartementById(int)
*/
@Override
public Departement getDepartementById(int id) {
// TODO Auto-generated method stub
Session session = HibernateUtil.getInstance().getSessionFactory().getCurrentSession();
Departement dept = new Departement();
try {
session.beginTransaction();
dept = (Departement) session.load(Departement.class, id);
} catch (HibernateException e) {
//LOGGER.error(e);
e.printStackTrace();
if (session.getTransaction().isActive()) {
session.getTransaction().rollback();
}
}
return dept;
}
/**
* @see com.my.dao.DepartementDao#getDepartementByNom(java.lang.String)
*/
@Override
public Departement getDepartementByNom(String nomDepartement) {
Session session = HibernateUtil.getInstance().getSessionFactory().getCurrentSession();
Departement result = new Departement();
try {
session.beginTransaction();
Criteria criteria = session.createCriteria(Departement.class);
criteria.add(Restrictions.eq("nomDepartement", nomDepartement).ignoreCase());
result = (Departement) criteria.uniqueResult();
session.getTransaction().commit();
} catch (HibernateException e) {
//LOGGER.error(e);
e.printStackTrace();
if (session.getTransaction().isActive()) {
session.getTransaction().rollback();
}
}
return result;
}
/**
* @see com.my.dao.DepartementDao#deleteDepartement(int)
*/
@Override
public void deleteDepartement(int id) {
// TODO Auto-generated method stub
Session session = HibernateUtil.getInstance().getSessionFactory().getCurrentSession();
session.beginTransaction();
Departement dept = (Departement) session.load(Departement.class, id);
session.delete(dept);
session.getTransaction().commit();
}
/**
* @see com.my.dao.DepartementDao#updateDepartement(com.my.dao.Departement)
*/
@Override
public void updateDepartement(Departement D) {
// TODO Auto-generated method stub
}
/**
* @see com.my.dao.DepartementDao#getAllDepartement()
*/
@Override
public List<Departement> getAllDepartement() {
// TODO Auto-generated method stub
Session session = HibernateUtil.getInstance().getSessionFactory().getCurrentSession();
session.beginTransaction();
return session.createQuery("from Departement").list();
}
}
我使用了官方调试功能$where = "O".$i;
$formula = '=IFERROR(IF(OR(C'.$i.'="výzva",C'.$i.'="string2"),E'.$i.'," ")," ")';
$objPHPExcel->getActiveSheet()->setCellValue($where, $formula);
$objPHPExcel->getActiveSheet()->getCell($where)->getCalculatedValue();
,并且在评估过程中我注意到“výzva”这个词是个问题。我的脚本以UTF-8编码,具有特殊字符的单元格正确地写在我最后创建的.xls文件中。当setCellValue与公式,在.xls文件中答案是正确的但有没有办法从这种类型的公式获得计算值?感谢您的建议