将树导出为ex​​cel

时间:2015-03-11 10:36:55

标签: java tree export-to-excel

我正在尝试将树导出到Excel工作表,我遇到了问题。

起初我使用的是RichTreeTable,我可以使用我的导出方法轻松导出数据。

 public static void exportDataDrillDownIndiComercial(FacesContext facesContext, OutputStream outputStream, RichTreeTable tree) throws IOException {

        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));

        CollectionModel treeModel = (CollectionModel) tree.getValue();

        JUCtrlHierBinding treeBinding = (JUCtrlHierBinding) treeModel.getWrappedData();
        List<JUCtrlHierNodeBinding> treeList = treeBinding.getChildren();

然而,他们已将其更改为ChildPropertyTreeModel, 现在我有:

public static void exportDataDrillDownIndiComercial(FacesContext facesContext, OutputStream outputStream, ChildPropertyTreeModel tree) throws IOException {
    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8")); 
    CollectionModel treeModel = (CollectionModel) tree;
    JUCtrlHierBinding treeBinding = (JUCtrlHierBinding) tree.getWrappedData(); //getWrappedData on tree or treeModel gives ClassCastException
    List<JUCtrlHierNodeBinding> treeList = treeBinding.getChildren();

每当我尝试getWrappedData()时,我都会遇到ClassCastException,而我尝试过的任何其他get都与JUCtrlHierBinding不兼容。 我该怎么办?

java.util.ArrayList cannot be cast to oracle.jbo.uicli.binding.JUCtrlHierBinding

0 个答案:

没有答案