function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pratik Raut 14Pratik Raut 14 

How to ignore # in js String to export data into Excel using JS

I have string that contain # in it eg. 'abc#test'. While I pasing this string to for export it is not exporting the string after #.
String tempString = 'abc#Test';
var csvStringResult = '"'+tempString +'"';

 var hiddenElement = document.createElement('a');
 hiddenElement.href = 'data:text/csv;charset=utf-8,' +encodeURI(csvStringResult );
            hiddenElement.target = '_new';
            hiddenElement.download = tableName+'_ExportData.csv'; 
            document.body.appendChild(hiddenElement); 
            hiddenElement.click();

I used the above code for exporting data into Excel file
Expected output in Excel File : abc#Test
Actual
output : abc
Anyone have any solution regarding this?

Thanks and Regards
Pratik Raut
 
ShirishaShirisha (Salesforce Developers) 
Hi Pratik,

Greetings!

You can split the string and append the string that you wanted to pass.

Example:

https://developer.salesforce.com/forums/?id=906F000000091hBIAQ

https://www.plus2net.com/javascript_tutorial/array-split.php

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.

Warm Regards,
Shirisha Pathuri