I have been unable to find any documentation for the .NET version of dhtmlxXMLWriter and RenderData, that explains use and format, there is no mention of them in the samples either. I am currently trying to setup a service to export a grid to Excel. Pretty much everything I have tried have lead to a blind alley.
Can you please explain, which documentation is missed ?
The export to excel for .Net has ready to use .Net export service
dhtmlx.com/x/download/regular/grid-excel-net.zip
and default clietn side code
docs.dhtmlx.com/doku.php?id=dhtmlxgrid:excel
will work for it
Normally there is no need for any custom interactions with .Net classes.
My initial problem is that grid.toExcel() only exports rows in memory, so I have been trying to setup a webservice to grab data from the database through a Connector, return it to a temporary grid and then export that. I can pull all the data up to the grid, and I can verify that its all there in the debugger, but when I execute grid.toExcel, nothing happens. Is there something that needs to be done to myGrid for the export to actually happen, are there a setting missing? myGrid is not part of the display.
Javascript is something like this. oGridProps.GridObject is the original grid that is paged, myGrid is the temporary grid I plan to use just for the export.
//Setup header, filter and sorting
for (nColumn = 0; nColumn < oGridProps.GridObject.getColumnsNum(); nColumn++) {
sColumnID = oGridProps.GridObject.getColumnId(nColumn);
asTableColumn = sColumnID.split("^");
stest += asTableColumn[1];
ftest += "#text_filter";
ctest += "str";
if (nColumn < (oGridProps.GridObject.getColumnsNum() - 1)) {
stest += ",";
ftest += ",";
ctest += ",";
}
}
myGrid.setHeader(stest);
myGrid.attachHeader(ftest);
myGrid.setColSorting(ctest);
myGrid.setSkin(SKIN_NAME);
myGrid.setInitWidths("10,*")
myGrid.attachEvent("onXLE", function (grid_obj, count) {
var sURL = "http://dhtmlxgrid.appspot.com/export/excel";
myGrid.toExcel(sURL);
});
myGrid.init();
sMyURL = "http://localhost/Handlers/ExportConnector.ashx?Table=Table1";
myGrid.load(sMyURL);
dp = new dataProcessor(sMyURL);
dp.setTransactionMode("POST", false);
dp.enableDataNames(true);
dp.init(myGrid);
Webservice is like this
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class ExportConnector : dhtmlxRequestHandler
{
private string _msConnStr; // Connection string to database
public override IdhtmlxConnector CreateConnector(HttpContext context)
{
_msConnStr = ConnectionString.GetTVConnectionString();
var sTable = context.Request.QueryString["Table"];
var connector = new dhtmlxGridConnector(
"SELECT * FROM " + sTable,
"ID",
dhtmlxDatabaseAdapterType.SqlServer2005,
cs.ConnectionString
);
return connector;
}