it doesn't load from the datasource tab. i'm sorry, i do not believe that
was what i said. it loads in response to a server side button click.
i examine this technique in detail in my forthcoming website, here is a
preview:
javascript:
title = "some title"
var header = '<?xml version="1.0"?><ss:Workbook
xmlns:x="urn:schemas-microsoft-com

ffice:excel"
xmlns:ss="urn:schemas-microsoft-com

ffice:spreadsheet"
xmlns:c="urn:schemas-microsoft-com

ffice:component:spreadsheet">
+<ss:Worksheet ss:Name="' + title + '"><ss:Table>';
//my data comes in streamed as string called payload, notice the delimiter
split
Rows = payLoad.split('|');
for(i = 0; i < Rows.length; i++)
{
target[index++] = "'<ss:Row>'";
if(Rows
.toString() != "")
{
Cols = Rows.toString().split('^');
target[index++]= "'<ss:Cell></ss:Cell>'";
for(j = 0; j < Cols.length; j++)
target[index++]= "'<ss:Cell><ss
ata ss:Type='String'>" + Cols[j] +
"</ss
ata></ss:Cell>'";
target[index++]= "'<ss:Cell></ss:Cell>'";
}
target[index++]= "'</ss:Row>'";
}
This peice of javascript extracts the raw data streamed in and applies
formatting tags transforming the data to xml
document.all.sp.XMLDATA = (header + target.join('') +
"'</ss:Table></ss:Worksheet></ss:Workbook>'");
This will load the data correctly formatted into the spreadsheet. This is
all happening client side. Remember, the data has come from the server side.
Here is the code which takes a dataset and transforms it into a payload
string
C-sharp
//build the data
string StartStreamDelimiter = "|";
string EndStreamDelimiter = "^";
strTempString.Append(StartStreamDelimiter);
for(int i = 0; i < dSet.Tables[0].Rows.Count; i++)
{
foreach(DataColumn myCol in dSet.Tables[0].Columns)
{
strTempString.Append(dSet.Tables[0].Rows[myCol].ToString().Trim());
strTempString.Append(EndStreamDelimiter);
}
strTempString.Append(StartStreamDelimiter);
}
strTempString.Replace("'","");
This comes in from the server side. All you have to do now is stream it out
to the page.
Regards