Question

Export To excel a list view with some modification

  • 6 November 2023
  • 4 replies
  • 69 views

Badge +1

Excel is getting downloaded well.

  1. I want to add space at the end of the header: I have tried adding space like :Edit the header names and add spaces at the end of each header. For example, you can modify "Date" to "Date " by adding spaces at the end. Its not working
  2. I want to Add this line as the first line 
    Active Charges,,,,,,,,,
    Please provide solution if anyone knows on it

 


4 replies

Badge +8

It seems like the headers are always trimmed, the only work-around I could find was to make the header literal and add a special character at the end, like this:

Item Name 

Userlevel 2
Badge +3

Hi Nagma_Nk

 

I do not think your 1st request is possible. 

Sanitizing whitespaces out of data is good practice, perhaps some more detail on your requirements and we could assist you with another plan

 

Are you trying to create a heading for you excel data?  If your data source is something like SQL then I suggest creating second List method. More detailed explanation below.

 

Consider the below SQL Table and corresponding SmartObject

SQL Table
SmartObject Properties​​​​​​
SmartObject Method

Now I create a stored procedure to generate my new data

-- =============================================
-- Author: Francois
-- Create date: 2023-11-07
-- Description: Lists data in [ExcelExport].[Data] With additional Headers
-- =============================================
CREATE OR ALTER PROCEDURE [ExcelExport].[Data.ListWithAdditionalHeaders]
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- temp table to store results and headers
DECLARE @results TABLE
(
[Field1] nvarchar(200) NULL,
[Field2] nvarchar(200) NULL
)

-- First we insert a header row
INSERT INTO @results ([Field1])
VALUES ('Active Charges,,,,,,,,,')

-- insert our data from our table next
INSERT INTO @results ([Field1], [Field2])
SELECT [Field1]
,[Field2]
FROM [ExcelExport].[Data]

SELECT * FROM @results
END
GO

Add the method to my Smart Object

Add new Method to Smart Object

 map the outputs/ inputs to existing properties

Map outputs/ inputs

 

Additional Smart Object Method

 

We change our export to excel rule to first call our new method and then export to excel

New actions

in the above I call the List method again.

 

Now the excel looks like this.

New row added

 

Let me know if this helps

Regards

Badge +1

I dont want it like this

I want it like this, Please find the below screenshot:

 

Userlevel 2
Badge +3

I do not think the Out of the Box functionality is going to work here.

I would recommend a custom integration that takes a template Excel file and populates a table in it.

This will required some form of Programming though.

Reply