Probably not the most effecient way of doing it ... but it seems to work ..
int WksDuplicate(Worksheet Wks, WorksheetPage &WPuser=NULL)
{
/*
Create a duplicate of the WorkSheet Wks as as a new sheet within the Parent Workbook Object ... (WPuser=NULL)
or the User-supplied Workbook Object "WPuser!=NULL"
Returns the index of the newly created Worksheet
*/
if(Wks.IsValid()==true)
{
WorksheetPage wpDest;
if(WPuser==NULL)
{
wpDest=Wks.GetPage();
}
else
{
wpDest=WPuser;
}
if(wpDest.IsValid()==true)
{
return (wpDest.AddLayer(Wks));
}
}
return (-1);
}
bool WksClear(Worksheet Wks, int Reduce=1, int SetAsBlank=1, int WarnMsg=0)
{
/*
Clears the Data from the Worksheet Wks
For info on the other parameters see the xFunction "wclear"
*/
if(Wks.IsValid()==true)
{
string strXFname="wclear";
XFBase xfwclear(strXFname);
if(xfwclear)
{
if(xfwclear.SetArg("w",Wks)==true && xfwclear.SetArg("reduce",Reduce)==true && xfwclear.SetArg("op",SetAsBlank)==true && xfwclear.SetArg("msg",WarnMsg)==true)
{
if(xfwclear.Evaluate()==true)
{
foreach (Column Col in Wks.Columns)
{
Col.SetLongName("");
}
return (true);
}
}
}
}
return (false);
}
void CreateNewSheet()
{
/*
Creates a new sheet within the same workbook using he current worksheet as a template ...
*/
Worksheet Wks(Project.ActiveLayer());
if(Wks.IsValid()==true)
{
int iLayr=WksDuplicate(Wks);
if(iLayr>=0)
{
WorksheetPage Wpg=Wks.GetPage();
if(Wpg.IsValid()==true)
{
Worksheet Wks1(Wpg.Layers(iLayr));
WksClear(Wks1);
}
}
}
}