Hi All, Thanks in advance. Please throw some light on the following:
1 . What is the simplest way to export a feature table content to excel.
2. How can I convert feature Table into html table
Thank you
This block of code should create a downloadable csv and add it as a button to a FeatureTable.
function customExportCSV() { let query = featureLayer.createQuery() query.where = '1=1' let csv = '' let headers = '' featureLayer.queryFeatures(query).then((featureSet) => { headers = Object.keys(featureSet.features[0].attributes).join(',') for (let i = 0; i < featureSet.features.length; i++) { const data = Object.values(featureSet.features[i].attributes).join(',') csv += data + '\n' } csv = headers + '\n' + csv downloadCSV(csv) }) } function downloadCSV(csv) { const csvFile = new Blob([csv], { type: 'text/csv' }); const downloadLink = document.createElement("a"); downloadLink.download = 'search_results.csv'; downloadLink.href = window.URL.createObjectURL(csvFile); downloadLink.style.display = "none"; document.body.appendChild(downloadLink); downloadLink.click(); } const downloadButton = new ButtonMenuItem({ label: 'Download CSV', iconClass: 'esri-icon-download', clickFunction: customExportCSV, autoCloseMenu: true }) const newTable = new FeatureTable({ view: mapView.view, layer: featureLayer, container: table, autoRefreshEnabled: true, id: props.key, menuConfig: { items: [downloadButton] } })
But I am looking a way to accomplish it in ArcGIS Javascript API
If you working in ArcGIS Pro, find the table you want in your table of contents in ArcGIS Pro, right click and from the context menu click on Data, the export. Rename the output to go where you want it to be and give it a .csv file extension which you can open it up in excel.
I don't know about #2 unfortunately.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.