Here is my complete code if that adds further clarity:

var csv_out = "Integration Statistics Report"+"\r\n";
csv_out += "From Date: "+document.getElementById('fromDate').value+" To 
Date: "+document.getElementById('toDate').value+"\r\n\r\n";
$(document).ready(function () {

   function exportTableToCSV(data, tableTitle) {
  var dt_cols = data.getNumberOfColumns();
  var dt_rows = data.getNumberOfRows();
   
   var csv_cols = [];
   
   // Iterate columns
   for (var i=0; i<dt_cols; i++) {
       // Replace any commas in column labels
       csv_cols.push(data.getColumnLabel(i).replace(/,/g,""));
   }
   //Give the table a title
   csv_out+=tableTitle+"\r\n";
   
   // Create column row of CSV
   csv_out += csv_cols.join(",")+"\r\n";
   
   // Iterate rows
   for (i=0; i<dt_rows; i++) 
   {
       var raw_col = [];
       for (var j=0; j<dt_cols; j++) {
           // Replace any commas in row values
           raw_col.push(data.getFormattedValue(i, j, 
'label').replace(/,/g,""));
       }
       // Add row to CSV text
       csv_out += raw_col.join(",")+"\r\n";
    }
    csv_out +="\r\n";
    }

   $(".downloadCSV").on('click', function (event) {
       //Exporting Links
       exportTableToCSV(kpiOverview_LINK_overall_chart_data, "LINK 
Integration Rate");
       exportTableToCSV(link_wfc_core_stats_data, "LINK - WFC Fallouts");
       exportTableToCSV(link_tm_core_stats_data, "LINK - TM Fallouts");
       
       //Exporting POIs
       exportTableToCSV(kpiOverview_POI_overall_chart_data, "POI 
Integration Rate");
       exportTableToCSV(poi_wfc_core_stats_data, "POI - WFC Fallouts");
       exportTableToCSV(poi_tm_core_stats_data, "POI - TM Fallouts");
       
       //Exporting PAs
       exportTableToCSV(kpiOverview_PNTADDR_overall_chart_data, "PA 
Integration Rate");
       exportTableToCSV(pa_wfc_core_stats_data, "PA - WFC Fallouts");
       exportTableToCSV(pa_tm_core_stats_data, "PA - TM Fallouts");
       csvData = 'data:application/csv;charset=utf-8,' + 
encodeURIComponent(csv_out);
       
       $(this).attr({
            'download': 'export.csv',
               'href': csvData,
               'target': '_blank'
        });
   });
});



On Wednesday, 19 August 2015 15:45:24 UTC-5, rishu oberoi wrote:
>
> I am using the solution mentioned here: Export to CSV using jQuery and 
> html 
> <http://stackoverflow.com/questions/16078544/export-to-csv-using-jquery-and-html?answertab=active#tab-top>
>
> The fiddle for this is: http://jsfiddle.net/terryyounghk/KPEGU/
>
> I will be calling the function exportTableToCSV multiple times as I have 
> three tables per category (Category1 has three tables, Category2 has three 
> tables and CAtegory3 has three tables).
>
> What I want is a separate sheet in the same excel file per category.
>
> How do I need to change the following code here to be able to create three 
> sheets in the same excel file - Category 1, 2 and 3?
>
> $(this).attr({
>                                 'download': 'export.csv',
>                                 'href': csvData,
>                                 'target': '_blank'
>                             });
>
> I have implemented all 6 tables in one sheet right now. If I can figure 
> this one out with this method, it will be great!
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/34969294-3b3b-457a-a1ed-919f4a5bb21e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to