Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 SSRS Export to Excel Multiple Sheets

Author  Topic 

Villanuev
Constraint Violating Yak Guru

478 Posts

Posted - 2012-03-22 : 04:22:08
Hi Forumer's

How do i make the resultset of my query when export to excel should have 3 sheets. every sheet have different result. Need your input. thanks.

Or do i have to make 3 separate dataset with different resultset.
what is the format of my SSRS report template where i used table.


how does my query should look like be?
My Query
1. generate all based on the critera
2. Generate summary based on ITEMID
3. generate summary by itemid and vendor

Thank you in advance.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-22 : 15:45:54
you can add a document map in ssrs report and do export to excel to get required data in different sheets. another way is to add grouping and then add a page break after group

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Villanuev
Constraint Violating Yak Guru

478 Posts

Posted - 2012-03-22 : 22:29:47
Hi Visakh16,

Thank for the reply..

Here is my Script. Every CTE have different result that should be display in SSRS or when exported to excel it should be in different tab. how should i breakdown this query? do i have to create separate dataset?

How do i add the document map with this query?

The CTE result should be like the following.
1. OpenPO -- this generate the details
2. OpenPO2 --this generate a summary report by etaMOnth/and Vendor
3. OpenPO3 --this is generate summary by ITEMID

;WITH OpenPO  --Generate Different result set
AS
(
Select
r.purchpoolid as Pool,
r.CREATEDDATETIME as CreatedDate,
p.Deliverydate as ETADate,
p.purchid as PurchaseOrder,
p.linenum as LineNumber,
r.Orderaccount as VendorAccount,
p.Itemid as ItemNumber,
p.Name as ItemName,
p.QtyOrdered as OrderQty,
p.PurchReceivedNow as RecvdQty,
p.RemainPurchPhysical as OpenQty,
p.PurchPrice as POUnitCost,
p.LineAmount as ExtPoCost,
r.vendorref as VendorReference,
r.Inventlocationid as Location,
Case When r.vendorref like '%Jan-Feb SB%' Then 'JAN SB'
When r.vendorref like '%JAN SB%' Then 'JAN SB'
When r.vendorref like '%Jan PO%' Then 'JAN PO'
When r.vendorref like '%Feb FC%' Then 'FEB FC'
When r.vendorref like '%Feb SB%'Then 'FEB SB'
When r.vendorref like '%Mar SB%' or r.vendorref like '%Mar-Apr SB%' Then 'MAR SB'
When r.vendorref like '%Mar BP%' Then 'MAR BP'
When r.vendorref like '%March FC%' Then 'MAR FC'
When r.vendorref like '%Mar PO%' Then 'MAR PO'
When r.vendorref like '%Mar FC%' Then 'MAR FC'
When r.vendorref like '%APR FC%'Then 'APR FC'
When r.vendorref like '%APR SB%'Then 'APR SB'
When r.vendorref like '%APR BP%'Then 'APR BP'
When r.vendorref like '%APR PO%'Then 'APR PO'
--When r.vendorref like '%APR FC%'Then 'APR FC'
When r.vendorref like '%April FC%'Then 'APR FC'
When r.vendorref like '%May SB%' Then 'MAY SB'
When r.vendorref like '%May FC%' Then 'MAY FC'
When r.vendorref like '%Jun FC%' Then 'JUN FC'
When r.vendorref like '%NOV%' Then 'NOV FC'
else ' ' End As ETAMonth
From TABLE1 as p
Left Outer Join TABLE2 as r
On p.Purchid = r.purchid
Where (r.CREATEDDATETIME <='2012-03-22'
and
p.purchstatus = 1
and
r.purchpoolid = 'RP'
and
r.inventlocationid in ('TRC','TCPW')
)
),
OPENPO2 AS --Generate Different ResultSet
(
Select
--Summary by ETA Month and VendorAccount
t.ItemNumber as SKU,
t.VendorAccount as Vendor,
t.ItemNumber+''+t.VendorAccount as SkuVendor,
JANSB=SUM(case when t.ETAMonth = 'JAN SB' Then t.OpenQty else 0 End),
JANPO=SUM(case when t.ETAMonth = 'JAN PO' Then t.OpenQty else 0 End),
FEBFC=SUM(case when t.ETAMonth = 'FEB FC' Then t.OpenQty else 0 End),
FEBSB=SUM(case when t.ETAMonth = 'FEB SB' Then t.OpenQty else 0 End),
MARFC=SUM(case when t.ETAMonth = 'MAR FC' Then t.OpenQty else 0 End),
MARSB=SUM(case when t.ETAMonth = 'MAR SB' Then t.OpenQty else 0 End),
MARBP=SUM(case when t.ETAMonth = 'MAR BP' Then t.OpenQty else 0 End),
MARPO=SUM(case when t.ETAMonth = 'MAR PO' Then t.OpenQty else 0 End),
APRFC=SUM(case when t.ETAMonth = 'APR FC' Then t.OpenQty else 0 End),
APRSB=SUM(case when t.ETAMonth = 'APR SB' Then t.OpenQty else 0 End),
APRPO=SUM(case when t.ETAMonth = 'APR PO' Then t.OpenQty else 0 End),
MAYSB=SUM(case when t.ETAMonth = 'MAY SB' Then t.OpenQty else 0 End),
MAYFC=SUM(case when t.ETAMonth = 'MAY FC' Then t.OpenQty else 0 End),
JUNFC=SUM(case when t.ETAMonth = 'JUN FC' Then t.OpenQty else 0 End),
NOVFC=SUM(case when t.ETAMonth = 'NOV FC' Then t.OpenQty else 0 End)
From OpenPO t
Where t.ETAMonth is not null
and t.VendorAccount in ('AC8','RNP','WCS')
Group by t.ItemNumber, t.VendorAccount, t.ItemNumber+''+t.VendorAccount
),
OPENPO3 AS
(
Select ItemNumber, SUM(OpenQTY) as OPENQTY
FROM OpenPO Where ETAMonth is not null Group by ItemNumber
)
Select * From OpenPo3;--Generate Different result set

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-22 : 22:34:14
as suggested it should be done in reporting services. are they fetched by single dataset?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Villanuev
Constraint Violating Yak Guru

478 Posts

Posted - 2012-03-22 : 23:31:09
Yes, I make it in one dataset. In case if i will break down into 3 dataset how do I create report format.

--this output should be exported to excel in 3 tab(sheet)
First report
all data with 15 column

2nd report
Summary with 10 column

3rd report
summary with 2 column

Go to Top of Page
   

- Advertisement -