generate ms excel with insert table having merge cells and formulas - apache-poi

by using Apache poi I can insert table but I have to apply formulas, and merge cells on table columns.
Example table
This is the requirement to generate excel file

Merge Cells:
CellRangeAddress address = new CellRangeAddress(firstRow, lastRow, firstColumn, lastColumn);
sheet.addMergedRegion(address);
please note, Indexes are zero based
Refer Java doc:
https://poi.apache.org/apidocs/dev/org/apache/poi/xssf/usermodel/XSSFSheet.html#addMergedRegion-org.apache.poi.ss.util.CellRangeAddress-
Add Formula:
String formula= "SUM(A1:A20)";
cell.setCellType(CellType.FORMULA);
cell.setCellFormula(formula);
Refer Java Doc:
https://poi.apache.org/apidocs/dev/org/apache/poi/ss/usermodel/Cell.html#setCellFormula-java.lang.String-

Related

Formula conversion from Google Sheets to Microsoft Excel

I am using 2 formulas for finding only duplicate values and listing them in another sheet. But when I downloaded the Spreadsheet as Microsoft Excel (xlsx), QUERY formula and Array function dont work on Microsoft Excel.
So I need your help about Microsoft Excel.
This is my formulas using on Google Sheets. How can I do that on Microsoft Excel? I am open to another formulas or solutions.
=INDEX( QUERY( QUERY( {'DATA'!A2:A}, "SELECT Col1, COUNT(Col1) GROUP BY Col1 ORDER BY Count(Col1) DESC"), "WHERE Col2 > 1",0) ,,1)
Test sheet:
https://docs.google.com/spreadsheets/d/1QJ7OLlrDg_9cZjwZFXjVFo0NHB6QvHl8MszQTYf4w2I/edit#gid=1428898146
With your shared example:
=UNIQUE(FILTER(DATA!A:A,COUNTIF(DATA!A:A,DATA!A:A)>1))
But this will be real slow, because it calculates each row of column A, also the empty ones.
To workaround we can use:
=LET(data,FILTER(DATA!A:A,DATA!A:A<>""),
u, UNIQUE(data),
FILTER(u, MMULT(--(TRANSPOSE(data)=u),SEQUENCE(ROWS(data),,1,0))>1))
In this case we can't use COUNTIF, because this requires a range, but using LET converts it to array. Therefore MMULT can be used.
Assuming data has a header, you can also use frequency:
=LET(data,DROP(TOCOL(Data!A:A,1),1),
u,UNIQUE(data),
f,DROP(FREQUENCY(data,u),-1),
HSTACK(FILTER(u,f>1),FILTER(f,f>1)))
If hstack is not available, you can try:
=LET(data,DROP(TOCOL(Data!A:A,1),1),
u,UNIQUE(data),
f,DROP(FREQUENCY(data,u),-1),
CHOOSE({1,2},FILTER(u,f>1),FILTER(f,f>1)))

How to add each row in one column just like excel in Power BI?

For instance: I have value 5 in cell A1 and when I do =5+A1 in excel it will do the job for the rest of the columns. How can I do exactly same in PowerBI? could anyone help me with this?
Thanks
Go to Table mode and click New Column.
Type MyColumn = Rates[size] + 5
Where [size] is base column as input (like A in excel) and MyColumn is the name of your new column.

Azure Data Factory - Import excel file with dynamic range2

I have a scenario where I'm converting Excel to CSV/TXT my excel file is formatted,which means main content starts at let's say A12 but end cell is dynamic( like Y400 or y700 etc..) that we don't know, in that case is there a possibility in ADF to define Excel range.
There is a range option in adf for excel dataset wherein you can mention the dynamic range as below:
A12
This would start from A12 and dynamically locate the end point
range :-
The cell range in the given worksheet to locate the selective data, e.g.:
Not specified: reads the whole worksheet as a table from the first non-empty row and column
A3: reads a table starting from the given cell, dynamically detects all the rows below and all the columns to the right
A3:H5: reads this fixed range as a table
A3:A3: reads this single cell
Use a DataFlow and follow the below steps:
1.Add your excel/CSV Source data set( Insert 'FileName' in column to save filename
2. add filter activity and insert 'length(trim(replace(trim(replace(replace(replace(replace(replace( toString(array(columns()) ),'null','' ), ',',''),FileName,''),'[',''),']','')),'""',''))) != 0'
3. Boom!! empty rows are gone.

Export values to Excel MS Access

I have a table in MS Access having 4 rows with four columns A, B, C, D
I want to export this records into an Excel sheet as follows,
Expected Output :
8 rows in Excel
How Excel should be like
4 rows will be queried from table
A clone of each row but with Column A prefixed with text 'Dummy'
Other column values for the cloned rows are constant
Example :
Table :
How Excel to be exported :
Each row has been cloned with only column A prefixed with text and rest of the column values are constant
I have few options to achieve in form through VBA and would like to hear which one would be optimised way
-Write a Query to select table values,
-Create a temp table (clone the structure of existing table)
-Loop through the Record-set which has queried values
-Fill the Temp table's first column value with Record-set's A column value with prefixed harcoded text and other column values are hardcoded as well
-append two table and export into Excel
-Query from table and export into Excel
-Loop through table and fill Excel cell A6 with tables field(1) with prefix
-Query from table and export into Excel
-Append the excel with hardcoded values for additional 4 rows (not sure append is possible)
Please suggest which way is possible and happy to hear other options I miss.(Never used MS Access before and this is my first hands on. Based on tutorials I got through, I come with above options)
I would suggest writing a query to select the data then union to that query the second dataset you want. Would look something like
SELECT A, B, C, D FROM tble
UNION ALL
SELECT "PREFIX " & A, "IDE", TRUE, FALSE FROM table
Then output the result of this query to excel.

Export a List&Label table with formula to Excel

I have an existing List&Label report containing a table with three columns:
col1 = valueA
col2 = valueB
col3 = valueA + valueB
When exporting these list to excel, the resulting excel table contains only values in all three columns.
Example export:
I tried to enter the formula for col3 as text, but then Excel also interpreted it as text.
Is there a way to export the table with List&Label to Excel, so that I have a working formula in excel?
Unfortunately - no. As List & Label has its own formula language that isnt't entirely translateable to Excel, there is no layer for this purpose - all values are exported as is. I'd export just columns A and B and add the formula to the resulting sheet. If this is something you need to do often/automatically, you could use VBA to post process the sheet. Here is a primer how to do that.
I'm new to List & Label and I'm evaluating it currently for further use. While my research to the product I found this article which describes new feature within the export format to Excel and meanwhile formulas are supported in the latest version - look there: Generating Excel Formulas in Worksheets

Resources