Export DataGrid to Excel

Hello,
I populated a datagrid using a query. Now I want to export
the content of the datagrid to Excel.
Is this possible?
I don't want to use the query to Export to Excel.
I want to Export from the datagrid itself.
Anyone has an idea how to export my datagrid to Excel in
flex?
Thx

Code is below. I simplified it a bit for this post, I hope it
still works ;-)
Couple of assumptions
1) My dataproviders are XMLListCollections - you have to
adapt that if you are using something else
2) I set a dataField on the datagrid columns for the XML
attribute I want to read
I am sure there are better / more generic ways of doing this,
but this works for me right now and I blew a lot of time on this
when I first came across the problem. If you find a better solution
let me know ;-)
public static function
copyGridData(srcDataGrid:DataGrid):void {
var outputA:Array = new Array();
// header
var headerA:Array = new Array();
var columns:Array = srcDataGrid.columns;
for each (var col:DataGridColumn in columns ) {
headerA.push(col.headerText);
outputA.push(headerA.join("\t"));
// data
var data:XMLListCollection =
XMLListCollection(srcDataGrid.dataProvider);
for each (var r:XML in data) {
var rowA:Array = new Array();
for each (var col2:DataGridColumn in columns) {
if (col2.dataField != null) {
rowA.push(r.attribute(col2.dataField.substr(1,col2.dataField.length-1)));
} else {
rowA.push("");
outputA.push(rowA.join("\t"));
// copy onto the clipboard
System.setClipboard(outputA.join("\n"));
Alert.show("Data copied to the clipboard.\nOpen target
application (e.g. Excel) and paste data.", "Data Copy");

Similar Messages

  • Unexplained Error while Exporting Datagrid to Excel

    Everything else seems to work ok (e.g. paging, master/detail functions, etc.) but the Export Datagrid to Excel isn't. I get the following:
    ErrorWe Recommend:Refreshing the page.Contacting your Portal administrator if problems persist.Accessing this Portlet at a later time.
    I am exporting it out as an attachment so Excel opens for the user. It works fine outside of the portal. Anyone know what I'm doing wrong?
    Paul

    I'm using the standard Microsoft ASP.NET 1.1 Datagrid control. Here is my routine that gets launched from a LinkButton Control...
    privatevoidExportDataGrid(){Response.Clear();Response.Buffer= true;Response.ContentType = "application/vnd.ms-excel"; Response.AppendHeader("Content-Disposition", "attachment;filename=Lead_FeedBack.xls");Response.Charset = "";
    this.EnableViewState = false; System.IO.StringWriter oStringWriter = newSystem.IO.StringWriter(); System.Web.UI.HtmlTextWriter oHtmlTextWriter = newSystem.Web.UI.HtmlTextWriter(oStringWriter);
    // Create a DataGrid control and Pass content from first DataGrid to itDataGrid DataGrid2 = newDataGrid();DataGrid2 = DataGrid1;this.RemoveControls(DataGrid2);
    //Lets make it a generic looking spreadsheetDataGrid2.HeaderStyle.BackColor = Color.LightGray;DataGrid2.AlternatingItemStyle.BackColor = Color.White;DataGrid2.PagerStyle.BackColor = Color.LightGray;DataGrid2.HeaderStyle.Font.Bold = true;DataGrid2.RenderControl(oHtmlTextWriter);
    Response.Write(oStringWriter.ToString()); Response.End(); }
    Paul

  • PTWC 2.2 and Export Datagrid to Excel

    I have a portlet with an Image Button control that will export a Datagrid to Excel. Using the PT Web controls 2.2 I get a JavaScript Error (Object is Null or Nothing). It works fine outside of the portal. My current work-around is to use an IFrame. Has anyone else encountered this?
    Paul

    Have a look at this.
    http://www.cristalab.com/tips/exportar-datos-de-flex-a-excel-c70300l/

  • How to export datagrid to Excel

    I want to export data from a datagrid to Excel. I heard about
    the use of Clipboard, but can't figure out how to use it.
    Can anyone give me a nice solution, how to do this?
    Thx

    Hi michael,
    I'm trying to do this: in my application I have a datagrid
    and I have a button to export the datagrid in Excel. When the user
    click on the button, I need to open a new html window where the
    data are showed in the excel format (may be also csv).
    I read that you have a solution to show the excel document.
    Are you available to share an example of the code or provide me a
    link on the web where I can find it?
    Any suggestion will be appreciated.
    Thank you very much.
    Regards

  • Export DataGrid into Excel

    Hi All,
       Can anybody share the code to export datagrid into an excel ?
    Thanks,
    Ravisha

    you can send the datagrid rows/values to server side and use some serverside script to create excel.

  • Flex 4: Exporting DataGrid to Excel qs

    Howdy,
    I already read the "Feature Specs" for Flex 4.
    And I don't think there's any feature that's going to export DG to Excel but I might be wrong.
    But I would like to hear someone from Adobe to confirm it before I try using as3xls library.
    Appreciate the help.
    Thank you.

    You will be able to do that in AIR2, see this example from Christophe Coenraets:
    http://coenraets.org/blog/2009/11/open-in-excel-another-air-2-mini-sample/
    Cheers,
    Oleg.

  • Export DataGrid to Excel. (Need Help @_@)

    Hi Guys..
         im newbie flex developer, i just want to ask how im going to export may data to excel??

    http://code.google.com/p/as3xls/

  • Export datagrid values to Excel

    Hi,
    Is there any way to export datagrid values to Excel other than saving values to clipboard or using API's??
    Thanks,
    Shruthi V

    Hi,
    Thanks a lot. The link was useful.

  • Issue while exporting report in Excel Format

    Hello,
    I am facing problem while exporting the report in Excel Format. After analysis, I think that it could be due to two reasons, either we are using wrong versions of Jars, or we are using wrong API. Here is the code, approaches and problems we are facing. Please help.
    First approach we are using is:
    // using basic API
    import com.crystaldecisions.reports.sdk.ReportClientDocument;
    // get client document from crystal report API and open the report by specifying the report name, with path
                   ReportClientDocument reportClientDoc = new ReportClientDocument();
                   reportClientDoc.open( reportPath, 0 );
                   // give chance to extending classes to configure the report document by POJO or by sql parameter etc, just adding the parameters infromation using ParameterFieldController
                   configureReportDocument( reportClientDoc, reportMetadata, reportData, reportContext );
                   // get data source of crystal report
                   Object reportSource = reportClientDoc.getReportSource();
                   // export the data - we have also tried with MSExcel format
                   ReportExportFormat exportFormat =  ReportExportFormat.recordToMSExcel;
                   LOGGER.debug( "exportFormat[" + exportFormat + "]" );
                   ByteArrayInputStream byteArray = (ByteArrayInputStream) reportClientDoc.getPrintOutputController().export(
                             exportFormat );
    Problem Faced: Specified Excel format is not supported.
    Second Approach: We come to know that excel format is supported with new releases and with occa package.
    Then we tried with import com.crystaldecisions.sdk.occa.report.application.ReportClientDocument; It ask to set the ReportServer. When we are trying to set the server as
                   reportClientDoc.setReportAppServer(ReportClientDocument.inprocConnectionString);
    Application is unable to find 'ReportClientDocument.inprocConnectionString' property. It seems like we are using some old jars. However we have downloaded the latest released jars for eclipse 2.
    Please help for it. Issue is to export the report in excel format, which is currently working fine for PDF. If this problem is related to Jars, please suggest the path to download the latest jars. We also looking for the latest jars like rasapp and rascore etc. But these are not available with Crystal Report for Eclipse 2 release.
    Waiting for urgent help. Thanks you..
    Regards,
    Mohit

    Hi,
    Send me Environment Details .
    Here is the code  snippet for exporting report to excel format:
    <%@ page import="com.crystaldecisions.sdk.occa.report.application.*" %>
    <%@ page import="com.crystaldecisions.sdk.occa.report.definition.*" %>
    <%@ page import="com.crystaldecisions.sdk.occa.report.data.*" %>
    <%@ page import="com.crystaldecisions.sdk.occa.report.lib.*" %>
    <%@ page import="com.crystaldecisions.sdk.framework.*" %>
    <%@ page import="com.crystaldecisions.sdk.occa.managedreports.*" %>
    <%@ page import="com.crystaldecisions.sdk.occa.infostore.*" %>
    <%@ page import="com.crystaldecisions.sdk.occa.report.exportoptions.*" %>
    <%@ page import="java.util.*" %>
    <%@ page import="java.io.*" %>
    <%
    String username ="Administrator";
    String password ="";
    String cmsname ="localhost:6400";
    String Authen ="secEnterprise";
         //connecting to Enterprise
         IEnterpriseSession es = CrystalEnterprise.getSessionMgr().logon(username,password,cmsname,Authen);
         //get the report App Factory form the Crystal Enterprise
         IReportAppFactory appFactory = (IReportAppFactory) es.getService("","RASReportService");
         //get the infostore service form the Crystal Enterprise
         IInfoStore istore = (IInfoStore) es.getService("","InfoStore");
         //get the report by name from crystal Enterprise
         IInfoObjects iobjects = istore.query("Select * From CI_INFOOBJECTS Where SI_NAME = 'sampleramz2.rpt' and SI_INSTANCE = 0 ");
         //open the report in the report doc object.
         ReportClientDocument Doc = appFactory.openDocument((IInfoObject)iobjects.get(0), 0, Locale.ENGLISH);
         // WORKING WITH THE PRINT OUTPUT CONTROLLER
         //Use the report documents PrintOutputController to export the report to a ByteArrayInputStream
         ByteArrayInputStream byteIS = (ByteArrayInputStream)Doc.getPrintOutputController().export(ReportExportFormat.recordToMSExcel);
         // EXPORTING THE REPORT
         //Create a byte[] (same size as the exported ByteArrayInputStream)
         byte[] buf = new byte[2000 * 1024];
         int nRead = 0;
         //Set response headers to indicate pdf MIME type and inline file
         response.reset();
         response.setHeader("Content-disposition", "inline;filename=ramz");
         response.setContentType("application/xls");
         //Send the Byte Array to the Client
         while ((nRead = byteIS.read(buf)) != -1)
              response.getOutputStream().write(buf, 0, nRead);
         //Flush the output stream
         response.getOutputStream().flush();
         //Close the output stream
         response.getOutputStream().close();
    %>
    Let me know any information is needed,
    Regards,
    Rameez

  • How to reserve the page size when exporting to MS Excel 2010

    Hello. I have a report which exports to MS Excel 2010. I applied the page size as legal in Crystal Report and would like to use the same page size in Excel
    However, MS Excel print preview says the page size is letter.
    How could I keep the same page size in Excel as I applied in Crystal Report. We have a lot of business reports and would like to avoid applying page setting manually in Excel when users print them out each time.
    Thank you.

    Hi Christine
    I am in the process of writing a doc on the different options in CR and the "No Printer" option sis one of those. Seeing this post, made me wonder as this looked like a questionable behavior. My testing does not support your observations. Now, I did a very simple test;
    Created a report, set "No Printer", set the paper size and legal orientation. Exported to XLS - any format, and the export maintained legal paper size in all instance. I did a few other variations, but I can never get the report to export anything other than Landscape.
    Can you  please let me know the version of CR you are using?
    You may also want to attach the report here with saved data (to attach rename the rpt to txt, then in the reply hit on the "Use advanced editor" link and attach.
    BTW.; I am using CR 2013.
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • Exporting Data to Excel

    Hi guys! I'm pretty stuck atm so any help would be most gratefully received! I am now at a point where my program is controlling everything properly and reading the data from the logger correctly.
    I am using 8.5, using the DAQ assistant sampling at 10Khz reading the samples of the buffer at 1khz, across 8 channels and plotting this to a waveform chart. So far so good..
    My problem lies in exporting this to Excel, I started using the write to spreadsheet vi but this never properly worked and straight to excel would make life a whole lot easier!
    1) I'm expecting roughly 50,000 data points (5 seconds at 10kHz) off each channel, but is this more than Excel can handle? Anyway round this or do I need to take every 10th value or similar?
    2) I am only getting roughly 50 data points for each channel! What is going on here? I have tried converting the DDT to an array, autoindexing and then reading this outside the while loop. I have tried convert DDT to array, then using buil array function inside the while loop then exporting this. All to no avail!
    3) My values are roughly of the order or 0.00001 or lower, I can only get Excel to write values to 0.0001 decimal places, can i change this at all??
    I am trying to use the Excel Vi's supplied under the report generation pallett. So my problem is I'm expecting thousands of data points, I'm getting maybe a few hundred 0.0000 with the occasional 0.0001 thrown in for fun!
    Thanks
    Jon

    Hi Jon,
    in this vi I cannot find any writing routines... Maybe they are hidden in one of those missing subvis...
    Cleaned up the attachment nevertheless
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    Quench Velocity.vi ‏140 KB

  • Issue while exporting report to excel

    I have a report created using ssrs.
    In that i have set the body background property to an image
    And also set a header in the report
    Now while exporting it to excel, I need to remove the body background  image and header
    Need Help
    Thanks
    Abhinav

    The workaround is to use a parameter that control the hidden properties and image/value properties of the header contents and background image path respectively. We need to place the header contents to a textbox or a rectangle so that the "hidden"
    properties can be set or reset. Similarly for the image path or value properties of body section can be set or reset using expression. I am using external image URL. Refer below step.
    1. Add a parameter "Export". Set the Available values
    as "Specify values" and add the below labels and values.
    Label                                 Value
    Header/Image                    Header/Image
    No Header/Image               No Header/Image
    For Default Values,
    Select Specify values option and add value as "Header/Image". Click Ok to close the parameter properties.
    2. As my header section contains a textbox and wanted to hide while i export, select the textbox properties and set the visibility/hidden expression as, =IIF(Parameters!Export.Value <> "Header/Image", True, False)
    3. Similarly in the report body properties, select the image source option as "External" and set the expression as,
    =IIF(Parameters!Export.Value <> "Header/Image", "" , "http://localhost/Testing/NEW_06.jpg")
    4. Preview the report and select the export parameter option as "No Header/Image".
    Regards, RSingh

  • Historical Report - export report in excel format

    Hi,
    We are on UCCX 8.0 (SU2). We have an issue with Historical when we tried to export report in excel format, the report does not display in correct column. It's very confusing. We could manually correct (rearrange) the column label but it take lots of time as we have so many reports.
    Is there anyway to fix this issue? Does anyone experience the same issue with Historical Report?
    I attached the pictures for example.
    Thanks,

    This type of behavior is a bug. I took a look in the bug toolkit and there are several defects filed against the Agent Summary report in 8.0 but not one that matches this behavior. I would venture a guess that a DE was sloppy when fixing another bug and introduced this on us.
    You should open a TAC case on this. It is also possible that this defect already exists but is not public in the toolkit yet.

  • Exporting report to Excel format

    We try to implement automated export to Excel Format but Crystal Report XI Java runtime doesnu2019t support export to Excel Format but pdf.
    Do I need to migrate to Crystal Report Eclipse 2.0 for exporting report in Excel format?
    Or I can deploy the Crystal Report Eclipse 2.0 Java runtime only for exporting to Excel Format?

    As I know, you can easily export the data from an MS Access Report to Excel, but it's really hard to get the formats exported along with the data, or just not doable at all. 
    Please see these links:
    http://www.howtogeek.com/howto/microsoft-office/export-an-access-2003-report-into-excel-spreadsheet/
    http://www.access-programmers.co.uk/forums/showthread.php?t=143884
    Also:
    https://social.msdn.microsoft.com/Forums/office/en-US/826a30c5-775e-4a51-b639-2ffb046bfe85/formatted-access-report-to-excel
    Also, keep in mind...it's easy to export the data from a report to Excel.  You can certainly setup Excel as a template, which has all the formatting applied and just sits on your disk drive...somewhere...waiting for you to dump new data into it from
    a new report...whenever you need it.
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • In SSRS , after exporting report in excel,wrap text property for cell and freeze column for SSRS table header not working in Excel

    I am working no one SSRS my table headers are freeze cangrow property is false and my report is working perfect while rendering data on RDL and i want same report after exporting in Excel also , i want my table header to be freeze and wrap text property
    to work after exporting in my report in excel but its not working ,is there any solution ? any patch ? any other XML code for different rendering ? 

    Hi Amol,
    According to your description, you find the wrap text property and fix column is not working after exporting into Excel. Right?
    In Reporting Services, when exporting to excel file, it has limitation for textbox.
    Text boxes are rendered within one Excel cell. Font size, font face, decoration, and font style are the only formatting that is supported on individual text within an Excel cell.
    Excel adds a default padding of approximately 3.75 points to the left and right sides of cells. If a text box’s padding settings are less than 3.75 points and is just barely wide enough to accommodate the text, the text may wrap in Excel.
    In this scenario, it supposed to be wrap text unless you merge cells. If cells are merged, word-wrap does not work correctly. If any merged cells exist on a row where a text box is rendered with the
    AutoSize property, autosize will not work. For the Fix Data Property, it can't be working in Excel. These are features when exporting to Excel. We can't change it because it's by design.
    Reference:
    Exporting to Microsoft Excel (Report Builder and SSRS)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

Maybe you are looking for