页面树结构

版本比较

标识

  • 该行被添加。
  • 该行被删除。
  • 格式已经改变。

在使用java api连接Smartbi操作电子表格的时候,常有如下问题:

...

1、导出分组报表报400错误

Image Added

原因分析:

一般是导出分组报表doExport方法传递的的type参数的值不对,比如应该传递EXCEL2007写成了EXCEL_2007。

2、清单报表导出Excel数据只有一页

使用的导出接口为smartbi.sdk.service.spreadsheetreport.SSReport 类的

...

解决方案:

把type参数值改为LIST_EXCEL导出

...

3、如何判断电子表格的报表类型

在全模块的License环境,总共有分组报表、清单报表、Excel融合分析三种电子表格报表类型。

...

报表类型reportType值
分组报表0
清单报表1
Excel融合分析2

目前java api文档没有接口获取电子表格的报表类型,可以参考如下方法获取reportType的值从而获取报表类型:实际第三方调用导出电子表格时,需要根据报表类型再确定导出的格式参数,但目前java api文档没有接口获取电子表格的报表类型,需要参考如下方法获取reportType的值从而获取报表类型:

代码块
languagejava
title获取电子表格的报表类型
linenumberstrue
   /**
	 * 获取电子表格类型
	 */
	public static int getSSReportType(){
		ClientConnector connector = new ClientConnector("http://192.168.1.10:17300/smartbi");
		boolean open = connector.open("admin", "admin");
		String resId = "I4028818a015f906290629888015f9505e9ea4c2a";  //电子表格资源id
		if (open) {
			InvokeResult remoteInvoke = connector.remoteInvoke("SpreadsheetReportModule", "openQueryInPage", new Object[] {resId,null});
			JSONObject originalResult = remoteInvoke.getOriginalResult();
			JSONArray jsonArray = originalResult.getJSONArray("result");
			JSONObject jsonObject = (JSONObject)jsonArray.get(0);
			JSONObject jsonObjectSet = jsonObject.getJSONObject("settings");
			int reportType = jsonObjectSet.getInt("reportType");
			if (reportType == 0) {
				System.out.println("分组报表");
			} else if (reportType == 1) {
				System.out.println("清单报表");
			} else if (reportType == 2) {
				System.out.println("Excel融合分析");
			}
			return reportType;
		}else{ 
			System.out.println("登录失败,无法获取报表类型");
			return -1;
		}
	}

...