#include "string.cxx"

//////////////////////////////////////////////////////////////////////////
//word
//替换计算书文字
int word(CString sKey, CString s)
{
	CString sVarScript = "";	
	sVarScript += X2S(sKey) + SPLITE_ATTVALUE;	
	sVarScript += X2S(s);
	JCallFunction("wordReplace", sVarScript.GetBuffer(), "");

	return 0;
}

//替换图片
int word(CString sKey, ents arid, double dWidth = 0.0);
int word(CString sKey, ents arid, double dWidth)
{
	CString sVarScript = "";	
	sVarScript += X2S(sKey) + SPLITE_ATTVALUE;	
	sVarScript += X2S(arid) + SPLITE_ATTVALUE;
	sVarScript += X2S(dWidth);	
	JCallFunction("wordReplaceImage", sVarScript.GetBuffer(), "");
	
	return 0;
}

int font(CString sKey, CString sKind, double d)
{
	CString sVarScript = "";	
	sVarScript += X2S(sKey) + SPLITE_ATTVALUE;	
	sVarScript += X2S(sKind) + SPLITE_ATTVALUE;
	sVarScript += X2S(d);
	JCallFunction("wordFont", sVarScript.GetBuffer(), "");
	
	return 0;
}


//追加计算书文字
int word(CString s)
{
	CString sVarScript = "";	
	//sVarScript += X2S(sKey) + SPLITE_ATTVALUE;	
	sVarScript += X2S(s);
	JCallFunction("wordAdd", sVarScript.GetBuffer(), "");

	return 0;
}

//追加图片
int word(ents arid, double dWidth = 0.0);
int word(ents arid, double dWidth)
{
	CString sVarScript = "";	
	//sVarScript += X2S(sKey) + SPLITE_ATTVALUE;	
	sVarScript += X2S(arid) + SPLITE_ATTVALUE;
	sVarScript += X2S(dWidth);	
	JCallFunction("wordAddImage", sVarScript.GetBuffer(), "");
	
	return 0;
}

//输出计算书文件
int wordOpen(CString sFile)
{
	CString sVarScript = "";	
	//sVarScript += X2S(s) + SPLITE_ATTVALUE;	
	sVarScript += X2S(sFile);
	JCallFunction("wordOpen", sVarScript.GetBuffer(), "");

	return 0;
}

//输出计算书文件
int wordOpen(CString sKey, CString sFile)
{
	CString sVarScript = "";	
	sVarScript += X2S(sKey) + SPLITE_ATTVALUE;	
	sVarScript += X2S(sFile);
	JCallFunction("wordInsert", sVarScript.GetBuffer(), "");
	
	return 0;
}


int wordSave(CString sFile)
{
	CString sVarScript = "";
	sVarScript += X2S(sFile);
	JCallFunction("wordSave", sVarScript.GetBuffer(), "");

	return 0;
}

//////////////////////////////////////////////////////////////////////////
//excel
//输出表格为模板
int excelOpen(CString sFile, int nSheet = -1, int nRow = -1, int nCol = -1, int nCopySize = 1);
int excelOpen(CString sFile, int nSheet, int nRow, int nCol, int nCopySize)
{
	CString sVarScript = "";
	sVarScript += X2S(sFile) + SPLITE_ATTVALUE;
	sVarScript += X2S(nSheet) + SPLITE_ATTVALUE;
	sVarScript += X2S(nRow) + SPLITE_ATTVALUE;
	sVarScript += X2S(nCol) + SPLITE_ATTVALUE;	 
	sVarScript += X2S(nCopySize);	 	
	JCallFunction("excelOpen", sVarScript.GetBuffer(), "");

	return 0;
}

//保存表格文件
int excelSave(CString sFile)
{
	CString sVarScript = "";
	sVarScript += X2S(sFile);
	JCallFunction("excelSave", sVarScript.GetBuffer(), "");

	return 0;
}

int excelSaveAs(CString sFileSc, CString sFileDe)
{
	CString sVarScript = "";
	sVarScript += X2S(sFileSc) + SPLITE_ATTVALUE;
	sVarScript += X2S(sFileDe);
	JCallFunction("excelSaveAs", sVarScript.GetBuffer(), "");
	
	return 0;
}

//输出表格
int excel(CString sValue, int nRow = -1, int nCol = -1);
int excel(CString sValue, int nRow, int nCol)
{	
	CString sVarScript = "";
	sVarScript += X2S(sValue) + SPLITE_ATTVALUE;
	sVarScript += X2S(nRow) + SPLITE_ATTVALUE;
	sVarScript += X2S(nCol);	 
	JCallFunction("excelSetCur", sVarScript.GetBuffer(), "");
	
	return 0;
}

int excel(CString sValue, CString sFile, int nSheet = -1, int nRow = -1, int nCol = -1, int nClose = 0);
int excel(CString sValue, CString sFile, int nSheet, int nRow, int nCol, int nClose)
{	
	CString sVarScript = "";
	sVarScript += X2S(sValue) + SPLITE_ATTVALUE;
	sVarScript += X2S(sFile) + SPLITE_ATTVALUE;
	sVarScript += X2S(nSheet) + SPLITE_ATTVALUE;
	sVarScript += X2S(nRow) + SPLITE_ATTVALUE;
	sVarScript += X2S(nCol) + SPLITE_ATTVALUE;
	sVarScript += X2S(nClose);	 
	JCallFunction("excelSet", sVarScript.GetBuffer(), "");
	
	return 0;
}

//图片
int excel(ents arid, CString sFile, int nSheet = -1, int nRow = -1, int nCol = -1, int nClose = 0);
int excel(ents arid, CString sFile, int nSheet, int nRow, int nCol, int nClose)
{
	CString sVarScript = "";
	sVarScript += X2S(arid) + SPLITE_ATTVALUE;
	sVarScript += X2S(sFile) + SPLITE_ATTVALUE;
	sVarScript += X2S(nSheet) + SPLITE_ATTVALUE;
	sVarScript += X2S(nRow) + SPLITE_ATTVALUE;
	sVarScript += X2S(nCol) + SPLITE_ATTVALUE;
	sVarScript += X2S(nClose);	 
	JCallFunction("excelImage", sVarScript.GetBuffer(), "");
	
	return 0;
}


//查找表格内容
CString excelFind(int &nRow, int &nCol, CString sFind, CString sFile, int nSheet = -1, int nClose = 0);
CString excelFind(int &nRow, int &nCol, CString sFind, CString sFile, int nSheet, int nClose)
{	
	CString sVarScript = "";
	sVarScript += X2S(sFind) + SPLITE_ATTVALUE;
	sVarScript += X2S(sFile) + SPLITE_ATTVALUE;
	sVarScript += X2S(nSheet) + SPLITE_ATTVALUE;	
	sVarScript += X2S(nClose);	 
	JCallFunction("excelSet", sVarScript.GetBuffer(), "n|n|s");
	
	nRow = g_nJResult0;
	nCol = g_nJResult1;
	return g_sJResult0;
}

//得到表格内容
CString excelGet(CString sFile, int nSheet = -1, int nRow = -1, int nCol = -1, int nClose = 0);
CString excelGet(CString sFile, int nSheet, int nRow, int nCol, int nClose)
{	
	CString sVarScript = "";
	sVarScript += X2S(sFile) + SPLITE_ATTVALUE;
	sVarScript += X2S(nSheet) + SPLITE_ATTVALUE;
	sVarScript += X2S(nRow) + SPLITE_ATTVALUE;
	sVarScript += X2S(nCol) + SPLITE_ATTVALUE;
	sVarScript += X2S(nClose);	 
	JCallFunction("excelGet", sVarScript.GetBuffer(), "s");
	
	return g_sJResult0;
}

//得到表格范围
int excelRange(int &nRow, int &nCol, CString sFile, int nSheet = 0, int nClose = 0);
int excelRange(int &nRow, int &nCol, CString sFile, int nSheet, int nClose)
{	
	CString sVarScript = "";
	sVarScript += X2S(sFile) + SPLITE_ATTVALUE;
	sVarScript += X2S(nSheet) + SPLITE_ATTVALUE;
	sVarScript += X2S(nClose);	 
	JCallFunction("excelRange", sVarScript.GetBuffer(), "n|n");

	nRow = g_nJResult0;
	nCol = g_nJResult1;
	
	return 0;
}
