How to export array data into xlsx in React - excel

I am looking for a good library that allows us to export array data (table data) into a xlsx (excel) format. I also want to have options to display merged cell data and specify colors for cells.
I've been using react-csv, but it doesn't have an option to display merged cell data or change the color of the cell.

One library, that from the looks of it supports it is xlsx.

Related

Datatype of Text in export to Excel from DocXfactory

I am using DocXfactory to write data to XLSX which is coming from a table where the field is defined as text (CHARACTER). The cell type in Excel also turns into TEXT which implies that you cannot type a formula in such a cell. Is there a way to tell DocXfactory to use the "General" datatype in XLSX instead of "Text"? Thanks for any suggestions.
As you know, you can add formulas manually in the Excel template but you can also add formulas programmatically using the ttMeta temp-table.
You can enter Excel formulas using Excel syntax and functions but you can also use 4gl/abl buffer-field or calculated field names in formulas.
You can also reference a column previous row by adding :PrevRow option to the field name. The following options are also supported - :NextRow,:PrevCol,:NextCol.
Please have a look at the create_template_ttmeta.p procedure in the \progress\samples\src\excel directory.

Excel Numeric Format Data

I have this data that I exports from some ERP in Citrix to the same Excel in Citrix,
Some example when i paste:
Doc.Curr.
-4,248,057.00
-25,998,733.00
25,998,733.00
-192,534.00
-118,509.00
192,534.00
But when i export this to a Excel in MacOS doesnt recognize like a number format, only like data without format, how can i solve this?
Many systems that export to Excel produce text instead of number. This has to do with the way that the system report was built in the exporting system. For example, the system report uses spaces to separate report columns. Excel parses the data according to the spacing but will not convert the text to numbers. In such a case you need to do that yourself
There are several ways to convert text to numbers, including
copy a cell with a zero, use paste special to paste over the text that should be numbers, using the option to "Add"
use text to columns on one column of numbers
If you need to do that on a regular basis, you may want to look into Power Query (Get and Transform) to load the data and perform any cleanup in there. It will be faster in the long run.

Convert CSV to Excel and apply formatting to cells

I have a C++ application which calls the business logic and generates a CSV that contains different transaction data.
Business partner wants to have this CSV as an Excel file and with different formatting options such as headers with bold text and numbers formatting with commas, etc.
I can not find any option to do this in c++ but found that I can convert the CSV file to Excel using PowerShell. I am finding the below difficulty in PowerShell:
Though the amount fields are in number format - I can not see the
result as "1,234,56.00". It just shows like 123456 only. But when I
check the format option it shows 1,234.10.. I have added the line in
PowerShell as below:
$worksheet.columns.item(2).NumberFormat = "#,##0.00_);[Red](#,##0.00)"
I have multiple sections in the same work sheet with multiple header
sections. I need to format some of the texts in bold. I can
change the format to bold as below.
$worksheet.Range("1:1").Font.Bold = $True
But the issue for me is the report will generate different numbers of records based transaction details. So I can't take the cell range and decide to format statically.
Import you csv with import-csv command
Modify your column values with good format (cast, substring etc) into loop
Export into other temporary csv
Transform your temporary csv in Excel. You will found lot of code here
There is an excellent module for Excel here by Douge Finke
Regards,
Kvprasoon

SSRS - Columns Download to .CSV Despite Visibility Status

I have a Reporting Services 2012 table that hides certain columns based on parameter choices, since some choices will cause the dataset to exclude certain columns when run. So, a column such as PassportID would have a hiding criteria expression such as:
=IIF(Parameters!TransitMode.Value = "bus"
OR Parameters!TransitMode.Value = "train",True,False)
The columns are indeed hidden when the report is rendered, and when it is downloaded to Excel. The problem is that I need to download it to a .CSV file. The .CSV downloader in SSRS does not have a layout renderer that can preserve the hiding criteria the way Excel can.
I looked at the DataElementOutput property, but changing this from the "Auto" default only appears to be give the options of downloading or excluding unconditionally, rather than based on column visibility in the rendering.
Is there a way to exclude the entire rendered column from the downloaded .CSV?
The easy answer is to set the displayed value to a formula, using the Render format function. If the Render format is CSV, then set the "Displayed value" to be an empty string. The field will still be exported, but won't contain data.
That is, set the value of the textbox to something like:
=iif(Globals!RenderFormat.Name="CSV", "", Fields!MyDataField.Value)
A little bit more info:
SSRS 2012 and CSV export
Change the DataElementOutput from Auto to NoOutput.
DataElementOutput controls whether or not the data is included in the export. Column headers are already excluded by CSV and names of columns for CSV are derived from the name of the textbox for a data element. Visibility properties are not considered in the CSV export since visibility is a formatting feature.

Export and customize a crystal report in excel

I am having an issue is that while exporting a report to excel sheet, there are lots of spaces and empty cells between the data, as well as, the cells are merged.
Is there is a way to export the report and each field will be in a cell or to control that exportation, suppose my report looks like this:
No Trans_No
1 123
2 333
In my excel sheet, I would like
A B
No Trans_No
1 123
2 333
, But currently it is showing a merging of the cells and spaces , so instead of Trans_No will be in CELL B, it is in D.
So, is there is a way to control o export that?
mohs, welcome to StackOverflow.
Crystal Reports and Excel have very different methods and data structures. When exporting a .rpt into .xls format, Crystal has to make many compromises and judgement calls. Here are some suggestions:
Do you absolutely need to use Crystal in this process?
A. You can import data directly from your data source into Excel (without using Crystal) using Data->Import External Data.
B. You can export from Crystal into CSV format. If the Excel file is being made just for a machine to read it, CSV is a better option.
Keep your Crystal Report very simple.
A. After you drag & drop fields onto your design, do not resize or overlap them.
B. Make sure in your options, you have snap to grid checked.
C. Are your fields horizontally aligned? If not, they will probably be put on different rows.
D. If you are grouping data, you may want to suppress the group headers & footers.
If you are finding empty rows between your data, you can filter these out in Excel:
Select column
Data > Filter (Excel 2010)
Dropdown > uncheck 'Blanks'
I don't use Crystal Reports, but could you export to a CSV file, then import into Excel. The import will allow you to specify the delimiters and should format your data better.
From experience with exporting from older versions of Crystal to Excel, a couple of options:
(1) Export to CSV and open the CSV file in Excel.
This had the disadvantage that instead of appearing at the top of the report above the data values, the column headings would appear on every line of the output before the column values - like so:
No Trans_No 1 123
No Trans_No 2 333
This issue may have been resolved in CR XI - if not, the workround we used for this was to suppress column headings (so that only the values were included in the output), then copy and paste a standard spreadsheet heading for the report into the output in Excel.
(2) Consistently format all fields to the same, minimum size (typically, two grid widths), with columns aligned by snapping the left edge of fields to guidelines.
This produces output which is almost unreadable in the standard report viewer, but which should align correctly in Excel.

Resources