public static string SaveDatasetToFile(ServerDataSource dataSource)//string fullpathfilename, string filetype, string datasetName)
{
string dirPath = Path.GetDirectoryName(dataSource.FileNameWithPath);
string fileName = Path.GetFileName(dataSource.FileNameWithPath);//.Replace("'","\'");
string fullpathfilename = Path.Combine(dirPath, fileName); //dirPath + "\\" + fileName;
string datasetname = dataSource.Name;
string filetype = dataSource.Extension.ToUpper();
string worksheetname = null;
if (filetype.Equals("XLS") || filetype.Equals("XLSX")) worksheetname = "Sheet1";
// set some extra parameter here if needed. Like Excel sheetname. replace etc..
if (!filetype.Equals("SAV"))
return string.Format("UAsaveDataset(fullpathfilename=\"{0}\",filetype='{1}', newWorksheetName='{2}', dataSetNameOrIndex='{3}')", FormatFileName(fullpathfilename), filetype, worksheetname, datasetname);
else
return "";
}//Anil #5