How to convert html table with all its css properties into excel , by javascript or jQuery
hi,
<script type="text/javascript">
//working java script
function CreateExcelSheet()
var x = Table1.rows
var xls = new ActiveXObject("Excel.Application")
xls.Workbooks.Add
for (i = 0; i < x.length; i++) {
var y = x[i].cells
for (j = 0; j < y.length; j++) {
xls.Cells(i + 1, j + 1).Value = y[j].innerText
} xls.visible = true
function write_to_excel()
str = "";
debugger;
var mytable = document.getElementsByTagName("table")[0];
var rowCount = mytable.rows.length;
var colCount = mytable.getElementsByTagName("tr")[0].getElementsByTagName("td").length;
var ExcelApp = new ActiveXObject("Excel.Application");
var ExcelSheet = new ActiveXObject("Excel.Sheet");
debugger;
ExcelSheet.Application.Visible = true;
for (var i = 0; i < rowCount; i++)
for (var j = 0; j < colCount; j++)
str = mytable.getElementsByTagName("tr")[i].getElementsByTagName("td")[j].innerText;
ExcelSheet.ActiveSheet.Cells(i + 1, j + 1).Value = str;
//new funtion
function ExportToExcel(mytblId) {
debugger;
var htmltable = document.getElementById('Table1');
var html = htmltable.innerHTML;
window.open('data:application/vnd.ms-excel,' + encodeURIComponent(html));
//new funtion 2
function write_to_excel2() {
str = "";
debugger;
var mytable = document.getElementById("Table1");
var rowCount = mytable.rows.length;
var colCount = mytable.getElementsByTagName("tr")[0].getElementsByTagName("th").length;
var ExcelApp = new ActiveXObject("Excel.Application");
var ExcelSheet = new ActiveXObject("Excel.Sheet");
//ExcelSheet.Application.Visible = true;
for (var i = 0; i < rowCount; i++)
for (var j = 0; j < colCount; j++)
debugger;
// if (i == 0) {
// str = mytable.getElementsByTagName("tr")[i].getElementsByTagName("th")[j].innerText;
str = mytable.getElementsByTagName("tr")[i].getElementsByTagName("td")[j].innerText;
ExcelSheet.ActiveSheet.Cells(i + 1, j + 1).Value = str;
ExcelSheet.autofit;
ExcelSheet.Application.Visible = true;
DisplayAlerts = true;
CollectGarbage();
//csss
function excelExportHtml(Table1, css1)
debugger;
if (css1) {
var styles = [];
//grab all styles defined on the page
$("style").each(function(index, domEle) {
styles.push($(domEle).html());
//grab all styles referenced by stylesheet links on the page
var ajaxCalls = [];
$("[rel=stylesheet]").each(function() {
ajaxCalls.push($.get(this.href, '', function(data) {
styles.push(data);
return $.when.apply(null, ajaxCalls)
.then(function() {
return "<html><style type='text/css'>" + styles.join("\n") + "</style>\n" + table.outerHTML + "</html>";
else {
return $.when({ owcHtml: Table1.outerHTML })
.then(function(result) {
return "<html>" + result.owcHtml + "</html>";
//new
function ExportToExcel() {
$(document).ready(function() {
$("#btnExport").click(function(e) {
window.open('data:application/vnd.ms-excel,' + $('#Table1').html());
alert("jhhklhhklhklh");
//new
$(document).ready(function() {
debugger;
$("[id$=myButtonControlID]").click(function(e) {
window.open('data:application/vnd.ms-excel,' + $('div[id$=divTableDataHolder]').html());
e.preventDefault();
alert("k");
function excel()
{debugger;
var tableToExcel = (function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(table, name) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = { worksheet: name || 'Worksheet', table: table.innerHTML }
window.location.href = uri + base64(format(template, ctx))
</script>
i have tried all the above java script and jquery to convert an html table to excel, data are exporting correctly but i want that css of the table should also implent to excel thats not happening,even the property defined inside td and tr aare not implementing
in excel
Hi avinashk89,
Welcome to post in MSDN forums.
This is not the right forum for your question. Please post in
ASP.NET forums where you could get better support.
Thanks for your understanding.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Similar Messages
-
How to create a table with just its structure in Access 2013?
I have a front-end and back-end Access 2013 database. I want to send it to an MS Access development company. I cannot send it with any data because it has our members social security numbers and other personal identification data. In MS Access 2003
I could save a table with just its structure.
How do I save a table with just its structure? I want to learn how to do this.
Thanks for the help.
RobertOn the Create tab of the ribbon, click Table Design.
This opens the table design window, in which you can define fields and indexes without entering any data. Don't forget to save the design when you're done.
Regards, Hans Vogelaar (http://www.eileenslounge.com) -
How to convert internal table with dynamic fields to XML
Dear all,
I met a problem like the following:
The aim is to transform the following parameter to XML
IT_FIELD stores the dynamic filed name of the internal table,with these fields, the dynamic internal can be created by cl_abap_tabledescr=>create(it_field)
IT_VALUE stores the value of the internal table dynamically created with dynamic fields.
For example
IT_FIELD =>
line1: FIELD1
line2: FIELD2
line3: FIELD3,
three lines in this internal table.
dynamically created internal table structure FIELD1 FIELD2 FIELD3
And IT_VALUE=>
1 2 3 (First line)
11 22 33
two lines of data.
Do you have any idea about how to transform the IT_VALUE to XML here? And also the transformed XML to the IT_VALUE.( we may need remember IT_FIELD here for later XML to IT_VALUE.)
Hope I describe the problem clearly.
Any inputs will be appreciated.
Edited by: Max Tang on Jan 12, 2009 3:46 PM
Edited by: Max Tang on Jan 12, 2009 4:14 PMHi,
you need to implement a bit of coding for that.
With the 'do varying' statement abap provides a loop over those fields. Within this loop you can build up a new internal table with one entry for each period and amount.
kind regards
Siggi
PS: I am not very familiar with CO, but I guess there will be a standard extractor for that. -
How to convert the table with separate fields for every period
Hi there,
I have the table in R/3 called COSP. The table contains the separate fields for values of separate reporting periods, let's say Amount01, Amount02 etc. I need to extract this data to BW and load it into ODS, which contains the data like common key figure for amount and info object Fiscal Period. How to extract and tansform the data to be able to load it there?
I mean, how to change the row like:
100 100 200 200....
for rows like:
001 100
002 100
003 200
004 200
I hope you'll help,
KooyotHi,
you need to implement a bit of coding for that.
With the 'do varying' statement abap provides a loop over those fields. Within this loop you can build up a new internal table with one entry for each period and amount.
kind regards
Siggi
PS: I am not very familiar with CO, but I guess there will be a standard extractor for that. -
How to save a project with all its content?
Hello,
I am looking for a feature inside CS5 Premiere which would do something similar to pack in InDesign that not only saves the project file but packs all links into one folder.
Thanks in advance
WiktorThank you very much for your quick response!
-
Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.The Oracle documentation has a good overview of the options available
Generating XML Data from the Database
Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
You can also find some information in XML DB FAQ -
Hi guys n girls. How do you copy a whole table to create a new table with all cell sizes in tact? Thanks for your help. Jason.
when you copy n paste into a new table, all the cell sizes are changed.
is there a way to put in a new table from your templates into an existing file, different to the standard very basic ones in insert table.
I look forward to your answers. Your help is very much appreciated.
Also how do you search for question answers already written in this support area please.Hi Jason,
In Numbers 3, you can select a whole table by clicking once in the table to make it active, then click once on the "bull's eye" at the top left.
Now copy and paste. All formatting (and any cell content) is pasted intact. In Numbers 2.3 (Numbers '09) it is a little different for selecting a whole table. But I won't go into that unless you are using Numbers '09. Please reply.
I don't like the look of the tables in Insert Table. I keep custom tables in My Templates. I have set Numbers > Preferences > General > For New Documents > Use template: (name of my favourite custom template)
That opens when I launch Numbers, or ask for a new document (command n). Note that if you follow this preference setting, then Menu > File > New From Template Chooser (for another template) requires you to hold down the option key in that menu.
Regards,
Ian.
Message was edited by: Yellowbox. All formatting (and any cell content) is pasted intact. -
How to print a dialog box with all its components ?
Hi !
I've written an application.It has a dialog box [JDialog] containing following components:
1) 2 JLabels.
1) A JTextField.
3) A JTable with some values.
4) A JProgressBar.
5) A JButton.
6) An animated gif image.
I want to print the dialog box with all its components exactly as the are [ Except the button & animated gif ].
Would anybody please help me?
My Operating System: Windows XPThe article over at http://java.sun.com/developer/technicalArticles/Printing/Java2DPrinting/ has some helpful information on printing Swing components.
It suggests creating a subclass of the JComponent that you want to print, and have it implement Printable interface.
So, something like (note, uncompiled / untested code alert) :
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.HeadlessException;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import javax.swing.JDialog;
public class PrintableDialog extends JDialog implements Printable {
* Or whichever constructor you need...
public PrintableDialog(Frame owner, String title, boolean modal) throws HeadlessException {
super(owner, title, modal);
* Implementation of the Printable interface.
public int print(Graphics g, PageFormat pf, int pageIndex) {
if (pageIndex != 0) return NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D) g;
g2.translate(pf.getImageableX(), pf.getImageableY());
getContentPane().paint(g2);
return PAGE_EXISTS;
}Cheers,
John -
How to convert internal table data to PDF format
HI,
I have an internal table data having one field with 255 chars. length.I want to send that intenal table data as attachemnt with external mail. i am thinking of converting that data into PDF format and use the FM to send the mail. How to convert internal table data to PDF format.
KishoreIn which format is your data in the internal table currently. Is it returned by a smartform/script or its just data fetched from some database table into an internal table. Since its obvious that the data should appear in the PDF with some Layout, you should be using smartform to format the data properly. See the Link
Smartform to PDF to EMAIL
This shows convertion of smartform to pdf and send it through email
Regards,
Abhishek -
How to convert Internal Table to Cluster Table ?
How to convert Internal Table to Cluster Table ?
Use :
EXPORT itab TO DATABASE dbtab(ar) ID key.
<i>EXPORT obj1 ... objn TO DATABASE dbtab(ar) ID key.
Additions:
1. ... = f (for each field you want to export)
2. ... FROM f (for each field you want to export)
3. ... CLIENT g before ID key )
4. ... USING form
5. ... FROM wa (as last addition or after dbtab(ar))
In an ABAP Objects context, a more severe syntax check is performed that in other ABAP areas. See Implicit field names not allowed with clusters and Table work areas not allowed.
Effect
Stores a data cluster in database table dbtab. The specified objects obj1 ... objn (fields, structures, or tables) are stored as a single cluster in the database table dbtab.
The specified database table dbtab must have a standard structure.
The database table dbtab is divided into various logically-related sections (ar, two-character name).
You can export a collection of data objects (a data cluster) to a part of the database using a key (field key).
You can import individual data objects from this collection using the IMPORT statement.
Notes
In classes, you must always assign explicit names to the data objects you want to export, that is, you must use either addition 1 or addition 2.
In classes, you must always specify the work area explicitly, that is, addition 5 is obligatory.
The table dbtab that appears after DATABAE must be declared under TABLES (except in addition 5).
You cannot export the header lines of internal tables. If you specify the name of an internal table with header line, the system always exports the body of the table.
You cannot export data, object, or interface references.
The data is stored in the database, and is consequently not actually stored until a database commit occurs (see LUW). Until this point, you can undo all of your changes using a database rollback (see Programming Transactions).
Example
Exporting two fields and an internal table to the database table INDX:
TABLES INDX.
TYPES: BEGIN OF ITAB3_TYPE,
CONT(4),
END OF ITAB3_TYPE.
DATA: INDXKEY LIKE INDX-SRTFD VALUE 'KEYVALUE',
F1(4), F2 TYPE P,
ITAB3 TYPE STANDARD TABLE OF ITAB3_TYPE WITH NON-UNIQUE
DEFAULT KEY INITIAL SIZE 2,
WA_INDX TYPE INDX.
Fill the data fields before CLUSTR
before the actual export
INDX-AEDAT = SY-DATUM.
INDX-USERA = SY-UNAME.
Export der Daten.
EXPORT F1 FROM F1
F2 FROM F2
ITAB3 FROM ITAB3
TO DATABASE INDX(ST) FROM WA_INDX ID INDXKEY.
</i>
Regards -
Hi,
As the subject stats i am trying to convert HTML tables to an array. It is a desktop application basically to performs a http request and is returned with a HTML table. I cant change the way the data is returned. (The data is from FDM remote server and is hard coded).
here is a sample of the table. The table layout will remain the same, only the contents (files) will change.
<table width="100%" border="1">
<tr>
<td>File name<br> </td>
<td>Size<br> </td>
<td>URL<br> </td>
</tr>
<tr>
<td>notepad2.zip</td>
<td>258 KB</td>
<td><a href="http://www.flos-freeware.ch/zip/notepad2.zip">http://www.flos-freeware.ch/zip/notepad2.zip</a></td>
</tr>
<tr>
<td>TeddyGuess.zip</td>
<td>308 KB</td>
<td><a href="http://myhost.com/Guess.zip">http://myhost.com/Guess.zip</a></td>
</tr>
</table>So ive started and looking at my code i cant help but think there has to be a smarter way!!
public String getCompletedDownloads() {
String tableString = makeRequest("compdlds.req");
tableString = tableString.replaceAll(
"</td><td>Size<br> </td><td>URL<br> </td></tr>", "");
tableString = tableString
.replaceAll(
"<table width=\"100%\" border=\"1\"><tr><td>File name<br> ",
tableString = tableString.replaceAll("</table>", "");
tableString = tableString.replaceAll("<a href=\"", "");
tableString = tableString.replaceAll("\"", "");
return tableString;
}Please any help would be great.camickr wrote:
You could use a ParserCallback. It notifies you every time it finds a new HTML tag. Simple example:
[http://forums.sun.com/thread.jspa?forumID=57&threadID=696560]
Rob, you rock. I was thinking about how to parse some table data from a HTML page for a pet project just yesterday. Didn't know about the ParserCallback, but it seems to be a perfect fit for what I want to do. :-D -
I am trying to use Labview for mp3 huffman decoding. there are 34 predefined tables for lookup purpose. I tried build array control, but it is so hard to assign value with size of 16. What is the better way to create predefined array? And how to do lookup table with Labview?
IMHO, the best way to have something "predefined" is to read this data from a "setup/configuration" file (if you don't want to use "default settings" LV feature). The choice of the format for all the data that you want to store in some kind of configuration file is up to you.
Also, constructing a "lookup table" in LV doesn't seems different as for any other programming language. -
How to insert a table with variable rows in smart form
Hi all,
How to insert a table with variable rows in smart form?
Any help would be appreciated.
Regards,
Mahesh.Hi,
Right click the mouse->create->table
If you want 5 columns, you need to declare 5 cells in one line type of the table
Click on Table -> Details, then do the following
Line Type 1 2 3 4 5
L1 2mm 3mm etc
Here specify the width of the columns as many as you want..
then in the header/main area of the table, click create Table Line, Rowtype is L1, automatically 5 cells will come,In each cell create a text element, display the variable to be printed there. -
How to convert database table into xml file
Hi.
How to convert database table into XML file in Oracle HTML DB.
Please let me know.
Thanks.This not really a specific APEX question... but I search the database forum and found this thread which I think will help
Exporting Oracle table to XML
If it does not I suggest looking at the database forum or have a look at this document on using the XML toolkit
http://download-east.oracle.com/docs/html/B12146_01/c_xml.htm
Hope this helps
Chris -
After POSTing a simple form to an nph CGI using AJAX, Firefox appears to expect more and shows the spinning circle after the request is complete and the returned content is displayed in the browser window.
The javascript works OK with Internet Explorer.
The CGI returns Content-Length in the HTTP header.
submitForm.xml.onreadystatechange=function()
if(submitForm.xml.readyState==4)
// Everything ok here
How do I tell Firefox thats all its getting and to replace the spinning circle with the website favicon?
Browser O/Ss: Windows XP and openSUSE 2012.1
Server O/S: Linux (Mandriva 2009)
Httpd: Apache 2.2.22
Thanks.See if you can find the answer with the links here: <br />
http://www.google.com/search?q=site:developer.mozilla.org%20document.write%28%29&ie=utf-8&oe=utf-8&lr=lang_en
Maybe you are looking for
-
I have uninstalled and reinstalled 4 times now and the music that was purchased is "dead in the water" unless I can move it into my PC library. I'm following all the install prompts, but I keep getting the improperly installed warning. I'm not the mo
-
MM_XSLTransform.class.php
I am trying to successfully consume an outside rss feed and seem to be running into a php problem, do i need to do some configuration with this page? or some other php configuration to set it up?
-
have a macbook pro the fan wont stop running the keyboard light is not working and the it wont charge all happened all of a sudden what to do please.
-
Filtering the ALV List Display
Hi all. We had a requirement like filtering ALV List display. Suppose my ALV list dispaly contains 100 records and by using the standard filtering option ,I restricted it to 50 records and by clicking a check box for 20 records and delete button(Cus
-
How to uninstall downloaded apple folders
How do I uninstall/delete the following folders from my software? I've downloaded them from Apple but they don't work to my expectations and make my Macbook slower than it used to be. The are in the Installations folder in my Software. SpeechRecognit