ag-grid copy to clipboard with formatting/styles feature - ag-grid-angular

I want to copy data of ag-grid to clipboard with formatting.
I am able to copy the data without format/style.
Is the feature available in ag-grid so that i can copy format of data as well.
I am trying this in ag-grid(angular) to paste the date to excel.
Best Regards,
Kaleem

If you are referring to being able to copy the value with "html style and formatting" this is not possible in agGrid, and wouldn't necessarily be useful as you would be pasting HTML code into Excel.
You can read here for how to achieve Excel styling on export: https://www.ag-grid.com/javascript-grid-excel/
You can use the gridOptions method processCellForClipboard to prepare the data itself however you want for export.
However, if like me you desired to simply get access to the data from the column's ValueFormatter, below is the only way I was able to achieve this:
processCellForClipboard = (params: ProcessCellForExportParams) => {
let colDef:ColDef = params.column.getColDef();
if (colDef.valueFormatter){
return colDef.valueFormatter({
...params,
data: params.node?.data,
colDef: colDef
} as ValueFormatterParams);
}
return params.value;
};
The idea is, use the ValueFormatter to format the value as you want it displayed in the grid. This way, you can at least get the value formatted into a proper string when copying it from the grid.
Cheers

Related

how can i export my json object data to pdf format using angular 9..?

I am trying to export my json object into csv and pdf format.
i had tried using the jspdf package and htmlCanvas etc. for this but its not giving me the output as i wanted...
its generates the pdf but all the tables are coming in very large size or in image format,
i wanted it to be in proper table structure.
i had written some codes like this..
exportPDF(data,headersContent){
// this.Arraylist=data[0];
alert(this.Arraylist);
console.log("exportPDF"+this.Arraylist);
this.pdfService.ExportPdf(this.Arraylist);
// this.SaveAs(data,headersContent+'_report.pdf')
}
where data is the jsonObj and headerContent is the label or header for the table made from those json data.
please suggest any way to acheive this exporting...
and somewhere when i wanted to get the perticular data or access the nth data in json record it gives undefined error.
like if i want the 2filed(or data) from the 1st record of data using data.description or data['description'].
please suggest any solutions for this.
thanking you.

Hide JsonValue from log file using <flter-spec>

I'am trying to hide the Json value of the student field from log files using filter-spec,
this is my filter-spec :
after i applied the flter this is how the data is showing in the log file
all i want it is to replace ("student" : "testStudent") with ("student": "****") instead it is got replaced with ("student: ****)
does anyone have an example on how to hide the json value using filter-spec?
Thanks in advance
It is not actually possible replace a JSON value with a filter. You'd need to use a custom filter or custom handler in order to do this.
You could file a feature request though. It does seem like a decent idea for a filter to be able to filter values in structured formats.

Closed XML data validation for allowing any numbers

I want to add data validation such that it allows only numbers.CLOSED XML
I think you can do it in memory but you can also use the "Data Validation" in Excel.
But if you use the Excel's data validation you need to be sure that the data you will insert programmatically are only number.
Anyway you can create an excel's templete file with the excel's data validation and than use closedXML for getting the file's template and then insert the data.
Basically for getting the template you can use this code(C#):
var workbook = new XLWorkbook("BasicTable.xlsx");
Info at : https://github.com/ClosedXML/ClosedXML/wiki/Loading-and-Modifying-Files
For the excel's data validation here there are some example :
https://www.got-it.ai/solutions/excel-chat/excel-tutorial/data-validation/data-validation-how-to-allow-numbers-only

Parse tab separated text file in Google Sheets

I have a txt file available on the web which contains tab separated values (TSV/CSV) like this:
Product_IdtabColortabPricetabQuantityItem1 tabRed tab$5.2 tab5Item2 tabBlue tab$7.5 tab10
I imported the txt file into a Google Spreadsheet using the IMPORTDATA(url) formula. The problem is that now I need to split the text to columns. I tried the following formulas without success:
Split(A1,"\t")
Split(A1," ")
Split(A1,"<tab>")
another thing I tried is to to use the Substitute function, but I just can't figure out how to match the Tab character in Google Spreadsheets?
Pages strips tabs by default when you paste text using a standard paste. Tab delimited data can be pasted and automatically parsed using:
Right Click -> Paste special -> Paste values only
IMPORTDATA(url) seems to handle tabs automatically, as others have mentioned before, if the URL ends in ".tsv".
I had trouble trying to import a file from Dropbox even though the file was named "something.tsv", because the url was
"https://www.dropbox.com/s/xxxxxxx/something.tsv?dl=1"
I managed to solve the problem by adding a dummy query parameter to the url:
"https://www.dropbox.com/s/xxxxxxx/something.tsv?dl=1&x=.tsv"
NOTE: I know this question was asked back in 2014 and I am answering this question some 5 years later. I am posting the answer here in hopes that someone else who googles their way here will be saved the headache and can be helped by how I devised a solution.
SUMMARY OF THE ISSUE: By default the IMPORTDATA() function will properly process a tab-delimited file only if the file name ends with the extension .TSV
UPDATE Nov 14, 2019:
In a comment below, Poul shared that he has found an undocumented parameter for the IMPORTDATA() function by which you can specify the delimiter to split the data. As of writing this, the official documentation makes no reference to this delimiter.
In effect the documentation should look something like the following:
IMPORTDATA("url","delimiter")
So, if you wanted to force a file to be split on the TAB character, it would look something like
IMPORTDATA("url","\t")
PRIOR ANSWER:
UPDATE: I am leaving my original answer just in case it might be helpful if the answer above, which includes undocumented functionality, does not continue to work.
ORIGINAL ANSWER: After seemingly countless attempts, I figured out how to coax Google Sheets into importing a tab-delimited file regardless of the extension.
For those looking for the quick and dirty answer, copy the following into a cell of a Google Sheet to give it a try:
=ARRAYFORMULA(IFERROR(SPLIT(IMPORTDATA("https://iso639-3.sil.org/sites/iso639-3/files/downloads/iso-639-3_Latin1.tab"),CHAR(9),FALSE,FALSE)))
For those that want to know a bit more, I will try to explain how each of the nested functions are helping to create the final solution:
=ARRAYFORMULA( IFERROR( SPLIT( IMPORTDATA(URL-HERE) ,CHAR(9),FALSE,FALSE) ) )
IMPORTDATA() - the primary function that pulls in the data file from the web
SPLIT - split the row by tab, note the use of char(09) to generate the tab character; also note the use of FALSE for the last parameter which was required in my case to ensure empty cells were not collapsed together
IFERROR - used to catch situations where an import might fail, the error will be trapped and not returned to the spreadsheet
ARRAYFORMULA - this function ensures that every line in the file is parsed; without this, only the first line of the file would be returned to the spreadsheet
It turns out that IMPORTDATA(url) can import a tab separated file, but it expects the file name to have the .tsv extension. This is inconsistent with Excel, where a tab-separated export results in *.txt.
If you can ensure that you use a .tsv extension, then your problem is solved.
You can also use the Sheets UI to import the file (into a new Spreadsheet). Select File > Import..., then Upload > Select a file from your computer. When the file selection dialog opens, paste the URL into the file name field, and click Open. The file will be downloaded to your PC then uploaded to Drive, through the Import dialog that will let you choose the delimiter.
(Validated on Windows 8.1 with Chrome; I don't know how this will behave on other OSes or browsers.)
Edit: See this gist.
importFromCSV(string fileName, string sheetName)
Populates a sheet with contents read from a CSV file located in the user's GDrive. If either parameter is not provided, the function will open inputBoxes to obtain them interactively.
Automatically detects tab or comma delimited input.
I had luck using split() and indicating only a single space as the delimiter, even though the data i pasted in had tabs separating each "column": =SPLIT(A1, " ", True) where A1 had data separated by 1 or more spaces. It seems that pasting in TSV data results in conversion from tabs to spaces.
This could be done in two steps leveraging the fact that tab is essentially multiple spaces.
Steps are as follows:
Select the columns which have tab separated data. Then trim tab to single space by using Data -> Data cleanup -> Trim whitespaces.
Now usual Data -> Split text to columns should work out of the box or after selecting space as separator.

Exporting BIRT report into CSV

I am Using BIRT for reporting in my project.
The report shows correct value for amount(String) as 123456789123, but when i try to export the same report into csv, the csv file shows same amount as 1.234E11.
I want to value as 123456789123 in csv too.
Please help
Thanks
I imagine this is probably an issue with viewing it in Excel. Exporting data does not export format codes. Open the csv in notepad and you will see the correct data. If you export the report to excel you can set a custom format code like #####0 in the Format Number property in the properties editor for the data item.
If the number is too large excel will display the value like that. If you expand the column and set the column to number under format cells it will display correctly. You will need to save it as an excel workbook.
We just had this problem with the our BiRT reporting tool. When we opened the exported file in a text editor the number was formatted in scientific notation. This was a bug with one of Birt's custom formatters.
We had to look at org.eclipse.birt.report.engine.dataextraction.impl.CommonDataExtractionImpl and change the line
valueFormatters[i] = new NumberFormatter( patterns[i], this.locale );
to
String pattern = patterns[i] == null ? "Unformatted" : patterns[i];
valueFormatters[i] = new NumberFormatter( pattern, this.locale );
Setting the pattern to "Unformatted" made default format stay as a normal integer rather than scientific notation (via a decimal formatter).