DataGrid to Excel
I have a DataGrid and I want to press a button and have the
contents of the grid dump to excel. How can I do this can someone
show me an example?
Thanks
Well, you can pass the contents of the datagrid into an xml
format and pass it in an HTTPRequest to a Java servlet.
In the servlet, use the jexcel(jxl.jar) api to create an
Excel Spreadsheet using the data from the XML passed in.
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?
PaulI'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 -
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?
ThxCode 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"); -
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?
PaulHave 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?
ThxHi 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 -
How to Save Data from DataGrid to Excel Sheet?
Hi All,
I am trying to use Adobe Flex 3.0 for making web pages.
I want to save the data from DataGrid and Advanced DataGrid of Adobe Flex 3.0 to Excel Sheet file. I am trying Flex Help, but didn't find answer for it.
In the application there is a button for 'save' by pressing which the 'Save As' window should appear.
And giving the path to the '.xls' file, the data from DataGrid should be saved on that location in .xls format.
This is my requirement.
If anybody knows how to do this please help.
Thank You,
SharadHi
Using document.applet.saveAsCSVFile(); code you can not get data in proper format.
For one of my application i have stored the data from Grid to excel.
But i am not sure about Adobe Flex 3.0, my code will work or not.
Also you need to make the "Initialize and Script Activex Control Not marked as Safe" as enabled in your IE.
You can share ur email. So that i can send the code. Here I am not able to paste the code.
Thanks -
Copy data from datagrid to Excel
Hi,
I have a datagrid with lots of data.
I want to copy the data from the datagrid and paste it in
Excel.
Any idea how to do this?
ThxHi
Using document.applet.saveAsCSVFile(); code you can not get data in proper format.
For one of my application i have stored the data from Grid to excel.
But i am not sure about Adobe Flex 3.0, my code will work or not.
Also you need to make the "Initialize and Script Activex Control Not marked as Safe" as enabled in your IE.
You can share ur email. So that i can send the code. Here I am not able to paste the code.
Thanks -
Hi All,
Can anybody share the code to export datagrid into an excel ?
Thanks,
Ravishayou can send the datagrid rows/values to server side and use some serverside script to create excel.
-
Cant export the last data in datagrid to excel
Hi everyone.
I have data in all 14 rows in the datagrid .When I export to excel by click the MS Excel button,the data from 1 to 13 row are exported,but the data in the last row arent exported.
It used to work at B1 8.8 PL11.Now I am using B18.8 PL15 version.
Excel version : 2003
B1 version : 8.8 PL15
Do anyone know the reason and how to solve it.Thanks.Hi Joe.
The data is exported from the user defined form.
Here is my code
Dim matrix As SAPbouiCOM.Matrix
Dim oColumn As SAPbouiCOM.Column
Dim oDBDataSource As SAPbouiCOM.DBDataSource
oColumn = matrix.Columns.Item(CStr(609))
oColumn.DataBind.SetBound(True, "Q106Tbl", "U_GrpMask")
oColumn = matrix.Columns.Item(CStr(610))
oColumn.DataBind.SetBound(True, "Q106Tbl", "U_AcctCode")
oColumn = matrix.Columns.Item(CStr(611))
oColumn.DataBind.SetBound(True, "Q106Tbl", "U_AcctName")
oColumn = matrix.Columns.Item(CStr(612))
oColumn.DataBind.SetBound(True, "Q106Tbl", "U_Type")
Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit)
matrix.LoadFromDataSource() -
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/
-
Exporting Incoming Payments to Excel - Missing last line
Forum,
On 8.8 PL15 has anyone come across the following problem:
When in Incoming Payments for customers, I click on the Excel icon within SAP and save the file as a .TXT file.
I then open this up in excel and notice the last line is missing from the excel spreadsheet. This is irrespective of how many lines are on the Incoming Payments screen within SAP.
Regards,
JuanHi Juan,
It seems like bug in PL-15
check Cant export the last data in datagrid to excel
Thanks,
Neetu -
Flex 3 - Export to Excel?
Hi everyone, is it possible to export to Excel?
If I have a chart or a datagrid, is it possible to export it
to Excel?
Thanks.
-David.Hi, even I am looking for exporting a datagrid to Excel. It
would be great help if someone can give some details about the
Excel extensions ( I think an example would be much better if you
anyone has it).
Thanks,
-Raj -
Hi!
I am trying to export data from datagrid to Excel. Export goes just fine, but the page I make the export from stops responding. I.E. pressing the export button again won't do anything. After reload (by pressing F5) page it works normally until the next export. I made a simple code example that demonstrates the problem:
public class ExcelTesti : System.Web.UI.WebControls.WebParts.WebPart
Button excelButton = new Button();
public ExcelTesti()
this.ExportMode = WebPartExportMode.All;
protected override void Render(HtmlTextWriter writer)
excelButton.RenderControl(writer);
protected override void CreateChildControls()
excelButton.Text = "To Excel";
this.Controls.Add(excelButton);
excelButton.Click += new EventHandler(m_button_Click);
protected void m_button_Click(object sender, EventArgs e)
this.Page.Response.Clear();
this.Page.Response.AddHeader("content-disposition", "attachment;filename=PIexport.xls");
this.Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);
this.Page.Response.ContentType = "application/vnd.ms-excel";
Page.Response.BufferOutput = true;
this.Page.Response.Buffer = true;
EnableViewState = false;
this.Page.Response.Charset = "";
StringWriter strW = new StringWriter();
HtmlTextWriter htmlw = new HtmlTextWriter(strW);
htmlw.RenderBeginTag(HtmlTextWriterTag.Table);
htmlw.RenderBeginTag("tr"); //Add a row
htmlw.RenderBeginTag("td"); // Add a cell
htmlw.Write("Test");
htmlw.RenderEndTag(); //End of the cell tag
htmlw.RenderEndTag(); //End of the row tag
htmlw.RenderEndTag(); //End <Table>
this.Page.Response.Write(strW.ToString());
Page.Response.Flush();
Page.Response.End();
I found some threads with the same problem, but no solutions that helped me. For example
http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1572942&SiteID=17
http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=1369245&SiteID=17
There must be some way to do this. I have seen web parts that do this right.
Can anyone help me?
AnttiHi,
I am facing with the same issue. I think it is absolutely with Response.Clear(), which removing all the events and hence page is not reepsonding to any event.
I have a deployed a custom- webpart in to a sharepoint site, which is consisting of a summary html table, button control and Export to Excel button. Every thing is working except events are not fired after export to excel button is clicked. The code inside the export to excel is
Export to Excel Click event code:
Me.Page.Response.Clear() 'clear the response before writing excel stream
Me.Page.Response.ContentType = "application/vnd.ms-excel" 'set the response contenttype as excel
Me.Page.Response.Charset = String.Empty 'set response charset as string
'get the filename to be displayed on the response stream
'specifying the response stream as an attatchment in the header [to open the excel file in the seperate window]
Me.Page.Response.AddHeader("Content-Disposition", "attachment;filename=test.xls")
'write the content on to the screen
Me.Page.Response.Write(sbExcelString.ToString()) 'writing excel stream in the form of string
'end the response once done [otherwise unnecessary conent will be appended at the end of the excel file]
Me.Page.Response.End()
I think somewhere the issue with Response.Clear or Response.End.
As you said there is a remedy for this, but i cant use that remedy because i cannot use a new page becauce my code is entirely in to a custom control and i should not depend on any aspx page.
Please help out in solving this issue in the same custom control click event itself.
I think there is a solution, only thing how to attach the events when we use Response.Clear or Response.End method [but i dont know how do i do this].
Thanks in advance for your helpful message.
Mukthesh. -
How to avoid specified is out of bounds error in flex 4 mxml web application
how to avoid specified is out of bounds error in flex 4 mxml web application
hi raghs,
i want to add records in cloud.bt while adding the records if we enter existing record details and try to save again na it wont allow to that record.
that time the alert box should show this msg "This record is already existing record in cloud database.
ex: one company name called mobile. i am adding a employee name called raja now i save this record,its data saved in cloud DTO
again try to add same employee name raja under the same compny means it should through error.
I am give my code here please if any suggession tel.
CODE:
private function saveRecord():void
refreshRecords();
model.employeeDetailsReq=new EMPLOYEEDETAILS_DTO();
var lengthindex:uint=model.employeeDetailsReqRecordsList.length;
var i:int;
for (i = 0; i < lengthindex; i++)
if((model.employeeDetailsReqRecordsList.getItemAt(lengthindex).employ ee name==customerdet.selectedItem.employeename)&&
(model.employeeDetailsReqRecordsList.getItemAt(lengthindex).employeeN umber==customerdet.selectedItem.employeeID)){
Alert.show("you cannot Add Same CustomerName and Invoiceno again");
(when this line come the error through like this: Index '8' specified is out of bounds.
else
var dp:Object=employeedet.dataProvider;
var cursor:IViewCursor=dp.createCursor();
var employeename:String = employeename.text;
model.employeeDetailsReq.employename = employeename;
model.employeeDetailsReq.employeeNumber=cursor.current.employeeID;
var sendRecordToLocID:QuickBaseEventStoreRecord = new
QuickBaseEventStoreRecord(model.employeeDetailsReq, new
KingussieEventCallBack(refreshList))
sendRecordToLocID.dispatch();
<mx:Button id="btnAdd" x="33" y="419" enabled="false" label="Add" width="65" fontFamily="Georgia" fontSize="12" click="saveRecord()"/>
employeename and employeeID are datafields of datagrid. datagrid id=customerdet
employeeDetailsReqRecordsList---recordlist of save records
Thanks,
B.venkatesanI do not know for sure as to how to do this, but I found this on Adobe Cookbook
http://cookbooks.adobe.com/post_Import_Export_data_in_out_of_a_Datagrid_in_Flex-17223.html
http://code.google.com/p/as3xls/
http://stackoverflow.com/questions/1660172/how-to-export-a-datagrid-to-excel-file-in-flex
http://wiredwizard.blogspot.com/2009/04/nice-flex-export-to-excel-actionscript.html
This has a demo that works
http://code.google.com/p/flexspreadsheet/
Maybe you are looking for
-
Data loading issue from BW Production to BW Sandbox
Hello Guys, I am trying to load data from one info cube (Production) to another info cube (Sendbox) applying update rules for prototype model. I am not getting any error in monitoring window for Info Package. But what I see is '0 from 0 record
-
Hi, We run into different behavior of the Thread Context ClassLoader on OC4J 10.1.3.1.0 (which is OK) and OC4J 10.1.3.2.0 (here we have problems). It appeared in the Threads directly and indirectly (e.g. through Timer) created by our application. Thr
-
How to place into indesign a specific page of a multipage pdf document through bridge
Can anyone let me know if this is possible and if so how? Many thanks
-
Anyone elese having a problem with iMessage on iPad after update? Attempting to login says that my internet connection is bad but all other functions working on ipad
-
Hi, I need to create a user who can only access to OEM and run a job: the job execute a stored procedure that reads and writes to the oracle tables. The user must have the least set of privileges possible. How can I do? What privileges do I set?