Type TSExcelFile = Class
	///Version: V1.0 2022-08-08
	///适用于 Microsoft Excel? 2007 及以上版本创建的电子表格文档。支持 XLSX / XLSM / XLTM / XLTX 等多种文档格式。
	///纯TSL模块实现
	///Excel文件读写接口

	//缺省构造函数
	Function Create(); overload;
	Begin
		init();
	End;

	//构造函数，打开已经存在的excel文件
	//alias: string，文件目录别名
	//fname: string，文件名
	Function Create(alias, fname); overload;
	Begin
		init();
		OpenFile(alias, fname);
	End;

	//析构函数
	Function Destory();
	Begin
	End;

	//初始化
	Function init();
	Begin
		zipfile_ := new ZipFile();
		xml_ := new xlsxXml();
	End;

	///打开excel文件
	///alias: string，文件目录别名
	///fname: string，文件名
	///返回：[err, errmsg]
	Function OpenFile(alias, fname);
	Begin
		if not ifObj(zipfile_) then return array(-1, 'Create ZipFile object fail.');
		[err, errmsg] := zipfile_.Open(alias, fname);
		if err=0 then Begin
			workbook_ := new xlsxWorkBook(zipfile_, xml_);
			workbook_.Load();
		End;
		return array(err, errmsg);
	End;

	///新建excel文件
	///返回：[err, info]
	Function NewFile();
	Begin
		path := ExtractFileDir(ExtractFileDir(PluginPath()));
{$IFNDEF Win32}
		defaultFileName := path + '\\funcext\\TSOffice\\default.xlsx';
{$ELSE}
		defaultFileName := path + '/funcext/TSOffice/default.xlsx';
{$ENDIF}
		[err, errinfo] := OpenFile('', defaultFileName);
		if not err then return array(err, errinfo);

		if not ifObj(zipfile_) then return array(-1, 'Create ZipFile object fail.');
		zipfile_.Add(xml_.GetFileName('rels'), xml_.XmlHeader() + xml_.GetTemplate('rels'));
		zipfile_.Add(xml_.GetFileName('docProps_app'), xml_.XmlHeader() + xml_.GetTemplate('docProps_app'));
		zipfile_.Add(xml_.GetFileName('docProps_core'), xml_.XmlHeader() + xml_.GetTemplate('docProps_core'));
		zipfile_.Add(xml_.GetFileName('workbook_rels'), xml_.XmlHeader() + xml_.GetTemplate('workbook_rels'));
		zipfile_.Add(xml_.GetFileName('theme1'), xml_.XmlHeader() + xml_.GetTemplate('theme1'));
		zipfile_.Add(xml_.GetFileName('sheet1'), xml_.XmlHeader() + xml_.GetTemplate('sheet1'));
		zipfile_.Add(xml_.GetFileName('styles'), xml_.XmlHeader() + xml_.GetTemplate('styles'));
		zipfile_.Add(xml_.GetFileName('workbook'), xml_.XmlHeader() + xml_.GetTemplate('workbook'));
		zipfile_.Add(xml_.GetFileName('Content_Types'), xml_.XmlHeader() + xml_.GetTemplate('Content_Types'));
		workbook_ := new xlsxWorkBook(zipfile_, xml_);
		workbook_.Load();
		return array(0, 'ok');
	End;

	///保存文件
	///返回: [err, info]
	Function Save();
	Begin
		return zipfile_.Save();
	End;

	///另存为
	///alias: string，文件目录别名
	///fname: string，文件名
	///返回: [err, info]
	Function SaveAs(alias, fname);
	Begin
		return zipfile_.Save(alias, fname);
	End;

	///真实文件名
	///返回：string
	Function FileName();
	Begin
		return zipfile_.FileName();
	End;

	///获取工作表列表
	///返回: arry('Sheet1','Sheet2')
	Function GetSheets();
	Begin
		return workbook_.GetSheets();
	End;

	///获取工作表数
	///返回: integer
	Function GetSheetsCount();
	Begin
		return workbook_.GetSheetsCount();
	End;

	///获取工作表名
	///index: int，工作表索引
	///返回: [err, sheetname:string]
	Function GetSheetName(index);
	Begin
		return workbook_.GetSheets()[index];
	End;

	///设置工作表名
	///sourceName: string, 原工作表名
	///destName: string，目标工作表名
	///返回：[err, errinfo]
	Function SetSheetName(sourceName, destName);
	Begin
		return workbook_.SetSheetName(sourceName, destName); 
	End;

	///创建新sheet
	///sheet: string，工作表名称
	///返回: [err, info]
	Function NewSheet(sheet);
	Begin
		return workbook_.NewSheet(sheet);
	End;

	///删除sheet
	///sheet: string，工作表名称
	///返回: [err, info]
	Function DeleteSheet(sheet);
	Begin
		return workbook_.DeleteSheet(sheet);
	End;

	///获取总列数
	///sheet: string，工作表名称
	///返回: [err, TotalCols:int]
	Function TotalCols(sheet);
	Begin
		o := workbook_.GetSheetObj(sheet);
		if ifObj(o) then return array(0, o.TotalCols());
		return array(-1, '');
	End;

	///获取总行数
	///sheet: string，工作表名称
	///返回: [err, TotalRows:int]
	Function TotalRows(sheet);
	Begin
		o := workbook_.GetSheetObj(sheet);
		if ifObj(o) then return array(0, o.TotalRows());
		return array(-1, '');
	End;

	///获取单元格的值
	///sheet: string，工作表名称
	///axis: string，单元格坐标，如: "A6"
	///返回: [err, value:string]
	Function GetCellValue(sheet, axis);
	Begin
		o := workbook_.GetSheetObj(sheet);
		if ifObj(o) then return o.GetCellValue(axis);
		return array(-1, '');
	End;

	///设置单元格的值
	///sheet: string，工作表名称
	///axis: string，单元格坐标，如: "A6"
	///val: Var，可以是整数、字符串、数值型等；nil 不设置值(可以调用ClearCell方法清空单元格)，只设置属性
	///[opt:Tany]，可选参数，单元格属性，可以是xml字符串或天软数组
	///		 xml串：opt := '<c t="s" s="1"></c>';
	///		 数组： opt := array('t':'s', 's':'1');
	///		 属性t：单元格数据类型，不设置的话，数据类型为val的数据类型；
	///				t ->（'s' 共享字符串、'b' bool 类型、'e' 错误类型、'inlineStr' 内联字符串类型、nil 数字类型、'str' 公式类型）
	///		 属性s：单元格样式
	///返回: [err, info]
	Function SetCellValue(sheet, axis, val, opt);
	Begin
		o := workbook_.GetSheetObj(sheet);
		if ifObj(o) then return array(0, o.SetCellValue(axis, val, opt));
		return array(-1, '');
	End;

	///获取富文本格式
	///sheet: string，工作表名称
	///axis: string，单元格，如"A7"
	///返回: [err, richtxt:string]，参见SetCellRichText
	Function GetCellRichText(sheet, axis);
	Begin
		o := workbook_.GetSheetObj(sheet);
		if ifObj(o) then return o.GetCellValue(axis, 'RichText');
		return array(-1, '');
	End;

	///设置富文本格式
	///sheet: string，工作表名称
	///axis: string，单元格，如"A7"
	///richtext: string，xml串或富文本对象TSOffice('TRichText')
	///返回: [err, info]
	Function SetCellRichText(sheet, axis, richtext);
	Begin
		o := workbook_.GetSheetObj(sheet);
		if ifObj(o) then Begin
			if ifObj(richtext) then
				richtext := class(xlsxXml).Dom2Xml(richtext.Marshal());
			return array(0, o.SetCellValue(axis, richtext, array('t':'s'), 'RichText'));
		End;
		return array(-1, 'The Sheet is not exist.');
	End;

	///清空单元格
	///sheet: string，工作表名称
	///[TopLeft: string]，左上角坐标，可选参数
	///[BottomRight: string]，右下角坐标，可选参数，
	///		用法1：ClearCell();		//Clear整个sheet
	///		用法2：ClearCell('A2'); //Clear 'A2'单元格
	///		用法3：ClearCell('A5', 'D8'); //Clear矩形区间所有单元格
	///返回: [err, info]
	Function ClearCell(sheet, TopLeft, BottomRight);
	Begin
		o := workbook_.GetSheetObj(sheet);
		if ifObj(o) then return array(0, o.ClearCell(TopLeft, BottomRight));
		return array(-1, '');
	End;

	///设置公式
	///sheet: string，工作表名称
	///axis: string，单元格，如"A7"
	///formula: string，公式
	///返回: [err, info]
	Function SetCellFormula(sheet, axis, formula);
	Begin
		o := workbook_.GetSheetObj(sheet);
		if ifObj(o) then return o.SetCellFormula(axis, formula);
		return array(-1, '');
	End;

	///获取公式
	///sheet: string，工作表名称
	///axis: string，单元格，如"A7"
	///返回: [err, formula:string]
	Function GetCellFormula(sheet, axis);
	Begin
		o := workbook_.GetSheetObj(sheet);
		if ifObj(o) then return o.GetCellFormula(axis);
		return array(-1, '');
	End;

	///按行赋值
	///sheet: string，工作表名称
	///axis: string，起始坐标，如: "A4"
	///slice: array()，一维数组array(1,2,3,2,1,"hello")
	///返回: [err, info]
	Function SetSheetRow(sheet, axis, slice);
	Begin
		[err, col, row] := CellNameToCoordinates(axis);
		if err then
			return array(err, col);
		for i:=0 to length(slice)-1 do Begin
			[err, cell] := CoordinatesToCellName(col + i, row);
			//println('{}->{}',cell,slice[i]);
			SetCellValue(sheet, cell, slice[i]);
		End;
		return array(0, 'ok');
	End;

	///插入数据表
	///sheet: string，工作表名称
	///axis: string，左上角坐标，如: "A4"
	///data: table，数据表
	///[IncludeHeader: bool] 是否包括表头，默认FALSE
	///[IncludeIndex: bool] 是否自动添加索引号，默认FALSE
	///返回: [err, info]
	Function InsertTable(sheet, axis, data, IncludeHeader, IncludeIndex);
	Begin
		if not ifarray(data) or length(data)=0 then
			return array(-1, "Invalid Data.");
		if FieldCount(data)=0 then Begin //数据是一维数组
			return SetSheetRow(sheet, axis, data);
		End;
		[err, colNum, rowNum] := CellNameToCoordinates(axis);
		if err then
			return array(err, colNum);
		if IncludeHeader then Begin
			fields := FieldNames(data);
			if IncludeIndex then Begin
				fields := array("Index") union fields;
			End;
			[err, info] := SetSheetRow(sheet, axis, fields);
			if err then
				return array(err, info);
			rowNum ++;
		End;
		if IncludeIndex then Begin
			for i:=0 to length(data)-1 do Begin
				[err, cell] := CoordinatesToCellName(colNum, rowNum + i);
				if err then
					return array(err, cell);
				SetCellValue(sheet, cell, i+1);
			End;
			colNum ++;
		End;
		for i:=0 to length(data)-1 do Begin
			[err, cell] := CoordinatesToCellName(colNum, rowNum + i);
			if err then
				return array(err, cell);
			t := sselect * from data where thisrowindex = i End;
			//PrintLn("cell={},data={}->{}",cell, data[i],t);
			[err, info] := SetSheetRow(sheet, cell, t);
			if err then
				return array(err, info);
		End;
		return array(0, "OK");
	End;

	///读取数据表
	///sheet: string，工作表名称
	///TopLeft: string，左上角坐标，如: "A4"
	///BottomRight: string，右下角坐标，如: "B8"，为空获取从TopLeft开始的整张表
	///返回: [err, data:table]
	Function GetTable(sheet, TopLeft, BottomRight);
	Begin
		o := workbook_.GetSheetObj(sheet);
		if ifObj(o) then return array(0, o.Import(TopLeft, BottomRight));
		return array(-1, '');
	End;

	///插入列，在指定列前插入空白列
	///sheet: string，工作表名称
	///col: string 列名，如: "D"
	///返回: [err, info]
	Function InsertCol(sheet, col);
	Begin
		return workbook_.InsertCol(sheet, col);
	End;

	///插入行，在指定列前插入空白行
	///sheet: string，工作表名称
	///row: int
	///返回: [err, info]
	Function InsertRow(sheet, row);
	Begin
		return workbook_.InsertRow(sheet, row);
	End;

	///删除列
	///sheet: string，工作表名称
	///col: string，如: "D"
	///返回: [err, info]
	Function RemoveCol(sheet, col);
	Begin
		return workbook_.RemoveCol(sheet, col);
	End;

	///删除行
	///sheet: string，工作表名称
	///row: int
	///返回: [err, info]
	Function RemoveRow(sheet, row);
	Begin
		return workbook_.RemoveRow(sheet, row);
	End;

	///设置行高度
	///sheet: string，工作表
	///row: int，行
	///height: double
	///返回: [err, info]
	Function SetRowHeight(sheet, row, height);
	Begin
		return workbook_.SetRowHeight(sheet, row, height);
	End;

	///获取行高度
	///sheet: string，工作表
	///row: int，行
	///返回: [err, info]
	Function GetRowHeight(sheet, row);
	Begin
		return workbook_.GetRowHeight(sheet, row);
	End;

	///设置列宽度
	///sheet: string，工作表
	///startcol: string，开始列，如: "A"
	///endcol: string，结束列，如: "D"
	///width: double
	///返回: [err, info]
	Function SetColWidth(sheet, startCol, endCol, width);
	Begin
		return workbook_.SetColWidth(sheet, startCol, endCol, width);
	End;

	///获取列宽度
	///sheet: string，工作表
	///col: int，列
	///返回: [err, info]
	Function GetColWidth(sheet, col);
	Begin
		return workbook_.GetColWidth(sheet, col);
	End;

	///设置工作表默认列宽
	///sheet: string，工作表
	///width：double
	///返回: [err, info]
	Function SetSheetDefaultColWidth(sheet, width);
	Begin
		return workbook_.SetSheetDefaultColWidth(sheet, width);
	End

	///获取工作表默认列宽
	///sheet: string，工作表
	///返回: [err, width]
	Function GetSheetDefaultColWidth(sheet);
	Begin
		return workbook_.GetSheetDefaultColWidth(sheet);
	End

	///添加批注
	///sheet: string，工作表名称
	///axis: string，单元格，如"A7"
	///Author:string
	///comment: string
	///返回: [err, info]
	Function AddComment(sheet, axis, Author, comment);
	Begin
		o := getOj(sheet, 'xlsxComment');
		if not ifObj(o) then return array(1, 'The sheet is not exist.');
		return o.AddComment(axis, Author, comment);
	End;

	///添加图表
	///sheet: string，工作表名称
	///range:string，图表所处矩形区域，"A5:F10"
	///chart:TChart对象
	///返回: [err, info]
	Function AddChart(sheet, range, chart);
	Begin
		o := getOj(sheet, 'xlsxChart');
		if not ifObj(o) then return array(1, 'The sheet is not exist.');
		if not ifObj(chart) then return array(2, 'Invalid chart param.');
		return o.AddChart(range, chart);
	End;

	///获取图表列表
	///sheet: string，工作表名称
	///返回: [err, ChartList]
	Function GetCharts(sheet);
	Begin
		return workbook_.GetCharts(sheet);
	End;

	///单元格坐标切分
	///cell: string，单元格坐标
	///返回: [err, col:string, row:int]，"AK47" -> return array(0, "AK", 47);
	Function SplitCellName(cell);
	Begin
		return xlsx_call("SplitCellName", cell);
	End;

	///单元格坐标组合
	///col: string
	///row: int
	///返回 [err, cell:string]，参见SplitCellName
	Function JoinCellName(col, row);
	Begin
		return xlsx_call("JoinCellName", col, row);
	End;

	///列名转索引
	///name: string
	///返回 [err, index:int]，"AK" -> return array(0, 37);
	Function ColumnNameToNumber(name);
	Begin
		return xlsx_call("ColumnNameToNumber", name);
	End;

	///索引转列名
	///index: int
	///返回 [err, name:string]，37 -> return array(0, "AK");
	Function ColumnNumberToName(index);
	Begin
		return xlsx_call("ColumnNumberToName", index);
	End;

	///单元格坐标转索引
	///cell: string
	///返回 [err, col:int, row: int] "A2" -> [1,2]
	Function CellNameToCoordinates(cell);
	Begin
		return xlsx_call("CellNameToCoordinates", cell);
	End;

	///索引转单元格坐标
	///col: int
	///row: int
	///abs: bool ,true返回"$A$1"格式，false返回"A1"格式
	///返回 [err, cell:string] [1,2,true] -> "$A$2"
	Function CoordinatesToCellName(col, row, abs);
	Begin
		return xlsx_call("CoordinatesToCellName", col, row, abs);
	End;

	///RGB与HSL色彩空间色值转换
	///r: int
	///g: int
	///b: int
	///返回: [err, h:double, s:double, l:double]
	Function RGBToHSL(r, g, b);
	Begin
		return xlsx_call("RGBToHSL", r, g, b);
	End;

	///HSL与RGB色彩空间色值转换
	///h: double
	///s: double
	///l: double
	///返回: [err, r:int, g:int, b:int]
	Function HSLToRGB(sheet, h, s, l);
	Begin
		return xlsx_call("HSLToRGB", h, s, l);
	End;

	///新建样式对象
	///style: TStyle对象
	///返回: styleid
	Function NewStyle(style);
	Begin
		styleObj := new xlsxStyles('', self);
		return array(0, styleObj.GetStyleId(style));
	End

	///设置单元格样式
	///sheet: string，工作表名称
	///TopLeft: string，左上角坐标
	///BottomRight: string，右下角坐标
	///styleid: string，样式Id
	///返回: [err, info]
	Function SetCellStyle(sheet, TopLeft, BottomRight, styleid);
	Begin
		o := workbook_.GetSheetObj(sheet);
		if ifObj(o) then return array(0, o.SetCellStyle(TopLeft, BottomRight, styleid));
		return array(-1, '');
	End;

	///获取单元格样式Id，获取到的Id可以在复制单元格样式时，作为调用 SetCellValue、或SetCellStyle 函数的参数使用。
	///sheet: string，工作表名称
	///axis: string，单元格，如"A7"
	///返回: [err, datastyle: int]
	Function GetCellStyle(sheet, axis);
	Begin
		o := workbook_.GetSheetObj(sheet);
		if ifObj(o) then return array(0, o.GetCellStyle(axis));
		return array(-1, 'The sheet is not exist.');
	End;

	///设置工作表页眉页脚
	///sheet：string，工作表名称
	///headerFooter: xlsxHeaderFooter对象
	///返回：[err, info]
	Function SetSheetHeaderFooter(sheet, headerFooter);
	Begin
		o := getOj(sheet, 'xlsxHeaderFooter');
		if not ifObj(o) then return array(0, 'HeaderFooter对象不存在');
		o.SetHeaderFooter(headerFooter);
		return array(1, '');
	End

	///设置工作表可见性
	///sheet: string, 工作表名称
	///visible: bool
	///返回：[err, info]
	Function SetSheetVisible(sheet, visible);
	Begin
		return workbook_.SetSheetVisible(sheet, visible);
	End

	///获取工作表可见性
	///sheet: string，工作表名称
	///返回: [err, visibility: bool]
	Function GetSheetVisible(sheet);
	Begin
		return workbook_.GetSheetVisible(sheet);
	End;

	///设置行可见性
	///sheet: string，工作表
	///row: int，行
	///visible: bool
	///返回: [err, info]
	Function SetRowVisible(sheet, row, visible)
	Begin
		return workbook_.SetRowVisible(sheet, row, visible);
	End

	///获取工作表行可见性
	///sheet: string，工作表名称
	///row: int, 行
	///返回: [err, visible:int]
	Function GetRowVisble(sheet, row);
	Begin
		return workbook_.GetRowVisble(sheet, row);
	End

	///设置列可见性
	///sheet: string，工作表
	///col: string，列，如：'A'
	///visible: bool
	///返回: [err, info]
	Function SetColVisible(sheet, col, visible)
	Begin
		[err, col] := ColumnNameToNumber(col);
		if err then return array(-1, col);
		return workbook_.SetColVisible(sheet, col, visible);
	End

	///获取工作表列可见性
	///sheet: string，工作表名称
	///col: string，列
	///返回: [err, visible:int]
	Function GetColVisble(sheet, col);
	Begin
		[err, col] := ColumnNameToNumber(col);
		if err then return array(-1, col);
		return workbook_.GetColVisble(sheet, col);
	End

	///设置工作表页边距
	///sheet: string，工作表名称
	///margins: TMargins 对象
	///返回: [err, info]
	Function SetPageMargins(sheet, margins);
	Begin
		o := getOj(sheet, 'xlsxMargins');
		if not ifObj(o) then return array(0, 'The sheet is not exist');
		o.SetPageMargins(margins);
		return array(0, '');
	End;

	///获取工作表页边距
	///sheet: string，工作表名称
	///返回: [err, info]
	///无错误时返回TMargins对象
	Function GetPageMargins(sheet);
	Begin
		o := getOj(sheet, 'xlsxMargins');
		if not ifObj(o) then return array(0, 'The sheet is not exist');
		return o.GetPageMargins();
	End;

	///合并单元格
	///sheet: string，工作表名称
	///hcell: string，左上角坐标
	///vcell: string，右下角坐标
	///返回: [err, info]
	Function MergeCell(sheet, hcell, vcell);
	Begin
		return workbook_.MergeCell(sheet, hcell, vcell);
	End;

	///取消合并单元格
	///sheet: string，工作表名称
	///hcell: string，左上角坐标
	///vcell: string，右下角坐标
	///返回: [err, info]
	Function UnMergeCell(sheet, hcell, vcell);
	Begin
		return workbook_.UnMergeCell(sheet, hcell, vcell);
	End;

	///设置工作表视图属性
	///sheet: string，工作表名称
	///viewIndex: int，视图索引
	///sheet: object，TSheetView对象
	///返回: [err, info]
	Function SetSheetViewOptions(sheet, viewIndex, sheetView);
	Begin
		o := getOj(sheet, 'xlsxSheetView');
		if not ifObj(o) then return array(1, 'The sheet is not exist');
		return o.SetSheetViewOptions(viewIndex, sheetView);
	End;

	///获取工作表视图属性
	///sheet: string，工作表名称
	///viewindex: int，视图索引，viewIndex 可以是负数，如果是这样，则向后计数（-1 代表最后一个视图）
	///返回: [err, SheetView]
	Function GetSheetViewOptions(sheet, viewIndex);
	Begin
		o := getOj(sheet, 'xlsxSheetView');
		if not ifObj(o) then return array(0, 'The sheet is not exist');
		return o.GetSheetViewOptions(viewIndex);
	End;

	///设置工作表页面布局
	///sheet: string，工作表名称
	///pageLayout: pageLayout对象，属性:
	///			BlackAndWhite bool	//BlackAndWhite specified print black and white.
	///			FirstPageNumber int //FirstPageNumber specified the first printed page number. If no value is specified, then 'automatic' is assumed.
	///			PageLayoutOrientation string	//PageLayoutOrientation defines the orientation of page layout for a worksheet.
	///			PageLayoutPaperSize int	//PageLayoutPaperSize defines the paper size of the worksheet.
	///			FitToHeight int	//FitToHeight specified the number of vertical pages to fit on.
	///			FitToWidth int	//FitToWidth specified the number of horizontal pages to fit on.
	///			PageLayoutScale int	//PageLayoutScale defines the print scaling. This attribute is restricted to values ranging from 10 (10%) to 400 (400%). This setting is overridden when fitToWidth and/or fitToHeight are in use.
	///返回: [err, info]
	Function SetPageLayout(sheet, pageLayout);
	Begin
		o := getOj(sheet, 'xlsxPageLayout');
		if not ifObj(o) then return array(1, 'The sheet is not exist');
		return o.SetPageLayout(sheet, pageLayout);
	End;

	///获取工作表页面布局
	///sheet: string，工作表名称
	///返回: [err, option:pageLayout对象]
	Function GetPageLayout(sheet);
	Begin
		o := getOj(sheet, 'xlsxPageLayout');
		if not ifObj(o) then return array(1, 'The sheet is not exist');
		return o.GetPageLayout();
	End;

	///设置工作簿应用程序属性
	///appProps: TAppProperty对象，属性:
	///			Application		  string
	///			ScaleCrop		  bool
	///			DocSecurity		  int
	///			Company			  string
	///			LinksUpToDate	  bool
	///			HyperlinksChanged bool
	///			AppVersion		  string
	///返回: [err, info]
	Function SetAppProps(appProps);
	Begin
		o := getOj('', 'xlsxAppProperty');
		if not ifObj(o) then return array(1, 'AppProperty error!');
		return o.SetAppProps(appProps);
	End;

	///获取应用程序属性
	///返回: [err, props:TAppProperty对象]
	Function GetAppProps();
	Begin
		o := getOj('', 'xlsxAppProperty');
		if not ifObj(o) then return array(1, 'AppProperty error!');
		return o.GetAppProps();
	End;

	///sheet: string，工作表名称
	///返回: [err, info]
	Function SetDefaultSheet(sheet);
	Begin
		return workbook_.SetDefaultSheet(sheet);
	End

	///返回：[err, sheet]
	Function GetDefaultSheet();
	Begin
		return workbook_.GetDefaultSheet();
	End

	///设置工作表背景图片
	///pictrue: 图片对象
	///返回: [err, info]
	Function SetSheetBackground(sheet, pictrue);
	Begin
		o := getOj(sheet, 'xlsxImage');
		if not ifObj(o) then return array(1, 'The sheet is not exist.');
		return o.SetSheetBackground(sheet);
	End;

	///设置超链接
	///sheet: string，工作表名称
	///axis: string，单元格，如"A7"
	///hyplink：THyperLink对象
	///返回: [err, info]
	Function SetCellHyperLink(sheet, axis, hyperlink);
	Begin
		o := getOj(sheet, 'xlsxHyperLink');
		if not ifObj(o) then return array(1, 'The sheet is not exist.');
		return o.SetCellHyperLink(axis, hyperlink);
	End;

	///获取超链接
	///sheet: string，工作表名称
	///axis: string，单元格，如"A7"
	///返回: [err, hyperlink: THyperLink对象]
	Function GetCellHyperLink(sheet, axis);
	Begin
		o := getOj(sheet, 'xlsxHyperLink');
		if not ifObj(o) then return array(1, 'The sheet is not exist.');
		return o.GetCellHyperLink(axis);
	End;

	Function WorkBook();
	Begin
		return workbook_;
	End;

	Function XmlObj();
	Begin
		return xml_;
	End;

	Function Zip();
	Begin
		return zipfile_;
	End;

private
	Function getOj(sheetname, objname);
	Begin
		if not ifarray(objMgr_) then objMgr_:= array();
		k := sheetname + '.' + objname;
		o := objMgr_[ k ];
		if not ifnil(o) then return o;
		case objname of
		'xlsxMargin':
			o := class(xlsxMargin).NewObject(sheetname, self);
		'xlsxComment':
			o := class(xlsxComment).NewObject(sheetname, self);
		'xlsxStyles':
			o := class(xlsxStyles).NewObject(sheetname, self);
		'xlsxChart':
			return class(xlsxChart).NewObject(sheetname, self);//不缓存xlsxChart对象
		'xlsxHeaderFooter':
			o := class(xlsxHeaderFooter).NewObject(sheetname, self);
		'xlsxMargins':
			o := class(xlsxMargins).NewObject(sheetname, self);
		'xlsxSheetView':
			o := class(xlsxSheetView).NewObject(sheetname, self);
		'xlsxPageLayout':
			o := class(xlsxPageLayout).NewObject(sheetname, self);
		'xlsxAppProperty':
			return class(xlsxAppProperty).NewObject(self);
		'xlsxImage':
			o := class(xlsxImage).NewObject(sheetname, self);
		'xlsxHyperLink':
			o := class(xlsxHyperLink).NewObject(sheetname, self);
		End;
		if ifObj(o) then objMgr_[k] := o;
		return o;
	End;

	{
		TODO// 需要移除，待完成
	///设置工作表默认行高
	///sheet: string，工作表
	///height：double
	///返回: [err, info]
	Function SetSheetDefaultRowHeight(sheet, height);
	Begin
		return workbook_.SetSheetDefaultRowHeight(sheet, height);
	End

	///获取工作表默认行高
	///sheet: string，工作表
	///返回: [err, height]
	Function GetSheetDefaultRowHeight(sheet);
	Begin
		return workbook_.GetSheetDefaultRowHeight(sheet);
	End
	}


	zipfile_;	//压缩文件对象
	workbook_;	//WorkBook对象
	xml_;		//xlsxXml对象
	objMgr_;	//各种对象缓存、管理
End;
