Naming sheets in SSRS when imported to Excel - reporting-services

I have put page breaks in my SSRS report. When report imported to Excel, report is divided into different sheets according to page breaks. Is it possible somehow name those sheets? Thanks for assistance.

You can easily change the tab name by setting the "Page Name" field on the properties sheet of the group (in this example "Buyer") that is providing the page break.

You can't do that with standard SSRS, but I know you can do it with OfficeWriter by SoftArtisans.
It's a proprietary application which isn't cheap, but it let's you create a template in Excel which you can then export the report into. You can do stuff like create charts and pivot tables as well which get populated automatically.
We have used their product and it works well. Their app can also be used to generate other Office artifacts such as Word docs.
(BTW I have no affiliation with SoftArtisans)

But how can I Name each tab with different names?
As Randy pointed out, the PageName is used to name tabs when a report is exported to Excel. Normally you would use a field name for the PageName expression.
If your page breaks are due to a Group, you would probably want to use the name of the group as the PageName. For instance, if you had a report of sales by customer with a separate tab for each customer, you would probably want to use the customer name field as the PageName expression.
=Fields!Customer_Name.Value

If you add the left(buyer,5) etc..into your dataset, put this as the initial group in your report then (page break between each instance of a group) and also use this field as the page name..should do the trick

Navigate to the tablix properties. Type the "SheetName" you need under "PageName" expression. It is better to assign this property from a Global variable, but if you need a custom set name for each of your Excel tabs, this is the way.

Related

MS Access 2013 Using Expression Builder to only display the first 25 characters in a text field for a report

I use the MS Access 2013 Expression Builder regularly.
But one thing I've never managed is simply to show only the first (say 25) characters of of a text field on the report.
It would seem to be a no-brainer. I've done far more complex things in Expression Builder without an issue. But shortening a text field on a report always return #Type! no matter how I try to adjust the expression.
It would seem to me that all I need is:
=Left([CompanyName],25)
But it just doesn't work! The report shows a #Type! error.
I can do this no problem by creating a RecordSet SQL string and setting the report RecordSource to it (with OpenArgs). But I can't manage it in Expression Builder.
What am I doing wrong?
When you build expressions for a form, then ANY column that exists in the datasource can be used - EVEN if not placed on the form.
However, reports have a significant difference. Your expressions ONLY work against data bound controls. In other words, the control has to be on the report (no doubt in this case in the details section of the report.
What this means is you have to drop into the details section (and you can and should use in design mode - add existing fields:
So, you need to add the Company name field to the report.
Of course you don't want it to display, so you can delete the label part, and set the control visible part = false. Eg: this:
Remember, you can't have the control reference its self.
In your case, the control you dropped "most" likely is called CompanyName, and then you changing the datasource expression to its self!!!
The other way?
well, you need to RE-NAME your control!!!
If you JUST drop the control onto the report, then its name will be CompanyName.
But, you NOW using =left(CompanyName,25) which POINTS to its self!!!!
So, as noted, you can drop in a company name control and then set visible = false.
The other way, is to CHANGE the name of the control to be DIFFERENT then the company name.
So, you can use add fields, but then in the other tab, rename.
So, say I just dropped in a Description column, but want to use left(10) on it
So, we do this:
Note VERY careful how I re-named the control.
I can't use left(Description,10), since that would refer to the VERY SAME control that I am attempting to use the expression against!!!
I would be saying, please use left of a control called description, but that description s the expression I am wanting to execute against!!!!
So, re-name the control. And now I can do this:
Note the arrow in above - note VERY careful how the control name is DIFFERENT then the data expression (Description) in this example.
Note VERY careful, I can now place OTHER controls on the report, and reference now:
I can reference Description in the expression, OR I CAN USE DescripitonLEFT in that expression!!!!
As you can see, we need a way to distinguish which control we are referencing here. In fact, some developers i have known as a habit NEVER use the same name for their controls vs the datasource of the control for this reason.
In your case the very same expression, and very same control BOTH have the same name - and thus you can't evaluate the expression of a left(Descripiton,10) against the VERY same control with the VERY same name!!!
So, you have to dis-ambiguate the name and the expression you want. In this case CompanyName. As noted, your left("some control") is the VERY same name as your current control.
Try just re-name of the control you dropped into the report.

SSRS - Naming Excel Tabs based on Page Number/Contents

My SSRS Report has two 'pages'.
The first page [run time] shows a Text Box with the Criteria used for returning data.
The next page[s] has all the data.
I have given the Tablix Member for the Data pages the Page Name of 'Detail'.
When the report is exported to Excel, it is displayed on two Sheets.
The first Sheet [with the Criteria] is named "Sheet1".
The second Sheet [with all the Detail Data] is named "Detail" - which is how I want it.
How do I get the First Sheet [... currently being named "Sheet1"] to be named 'Criteria' when it is exported to Excel?
Can I use an Expression somewhere that says something like this:
IIf (PageNumber = 1, "Criteria", "Detail")
?
Thanks in advance!!
You don't actually need a conditional expression for this. You can use the PageName property to control the sheet names. You can give each table a separate page name. If there are no tables on the first page, insert a rectangle and give that a page name. In the Report properties there is also an InitialPageName you can use for the first page. Lastly, make sure that you do have a PageBreak defined, don't just let it roll over to the next page based on the height.

how to change sheet name in report-builder 2.0

I am building a report using report-builder 2.0 and i want to change the name of sheet while exporting data from ssrs to excel
Is there any way to change the name of default sheet name to custom sheet name ?
You can name the PageBreak in the properties of whatever it is configured for. For example, I have a report that has 7 different tables with the intent of it being exported to Excel with each table being its own separately named sheet. With the exception of the first table, every table has a page break configured for before the tablix. When I select the tablix, and go to properties, I can then name the PageName to whatever I would like the sheet to be named.
If I were to have the page break occur based on row groups in the tablix, I would select the Row Groups from the tablix, go to properties, and the page break, and then modify the PageName.
I also not found in report builder 2.0 version, I changed pageName by editing report file on 3.0 version cause there available pageName proporty. There is no any conflicts to editing with newer version.

SSRS - Changing the reference of element expressions to reflect dataset rename automatically

I am using the SQL Server Report Builder, and just changed the name of a dataset. Is there a way to make all the already existing elements in the report that reference the old name, to use the new name?
Doing each one manually is a lot of work, so any tips would be appreciated!
To do each field manually, I would have to enter the expression and change
=First(Fields!FieldName.Value, "OldDataSetName")
to:
=First(Fields!FieldName.Value, "NewDataSetName")
Your report is just an XML file. Open it in notepad and replace all occurrences of old name to new.

How to get named excel sheets while exporting from SSRS

Whenever a single page report is exported to excel, sheet in excel is named by the report name.
If a report has multiple pages, the sheets are named as sheet1, sheet2,....
Is there any way to specify sheet names in SSRS 2005 ?
solution:
Found this after some googleing:
Changing the Sheet names in SQL Server RS Excel: QnD XSLT
Will try out and post an update if it works.
Necromancing, just in case all the links go dark:
Add a group to your report
Also, be advised to set the sort order of the group expression here, so the tabs will be alphabetically sorted (or however you want it sorted).
'Zeilengruppe' means 'Target group'
'Gruppeneigenschaften' means 'Group properties'
Set the page break in the group properties
'Seitenumbruche' means 'Page break'
'Zwischen den einzelnen Instanzen einer Gruppe' means 'Between the individual instances of a group'
Now you need to set the PageName of the Tablix Member (group), NOT the PageName of the Tablix itselfs.
If you got the right object, if will say "Tablix Member" (Tablix-Element in German) in the title box of the properties grid. If it's the wrong object, it will say only "table/tablix" (without member) in the property grid's title box.
Note: If you get the tablix instead of the tablix member, it will put the same tab name in every tab, followed by a (tabNum)! If that happens, you now know what the problem is.
To export to different sheets and use custom names, as of SQL Server 2008 R2 this can be done using a combination of grouping, page breaks and the PageName property of the group.
Alternatively, if it's just the single sheet that you'd like to give a specific name, try the InitialPageName property on the report.
For a more detailed explanation, have a look here: http://blog.hoegaerden.be/2011/03/23/where-the-sheets-have-a-name-ssrs-excel-export/
In SSRS 2008 R2 use PageName property of page group:
http://bidn.com/blogs/bretupdegraff/bidn-blog/234/new-features-of-ssrs-2008-r2-part-1-naming-excel-sheets-when-exporting-reports
To add tab names while exporting to excel, I used the following method:
On the report design window, select the tablix object.
Open properties window of the tablix object.
Add the required tab name to the PageName property.
Run the report
Export the report to Excel.
Now the worksheet name is the same as the PageName property of the tablix object.
Put the tab name on the page header or group TableRow1 in your report so that it will appear in the "A1" position on each Excel sheet. Then run this macro in your Excel workbook.
Sub SelectSheet()
For i = 1 To ThisWorkbook.Sheets.Count
mysheet = "Sheet" & i
On Error GoTo 10
Sheets(mysheet).Select
Set Target = Range("A1")
If Target = "" Then Exit Sub
On Error GoTo Badname
ActiveSheet.Name = Left(Target, 31)
GoTo 10
Badname:
MsgBox "Please revise the entry in A1." & Chr(13) _
& "It appears to contain one or more " & Chr(13) _
& "illegal characters." & Chr(13)
Range("A1").Activate
10
Next i
End Sub
There is no direct way. You either export XML and then right an XSLT to format it properly (this is the hard way). An easier way is to write multiple reports with no explicit page breaks so each exports into one sheet only in excel and then write a script that would merge for you. Either way it requires a postprocessing step.
I was able to get this done following more complex instructions suggested by Valentino Vranken and rao , but here is a more simple approach , for a more simple report . This will put each table on a separate sheet and name them in Excel . It doesn't seem to have an effect on other exports like PDF and Word .
First in the Tablix Properties of of your tables under General , check either Add a page break before or after , this separates the report into sheets .
Then in each table , click the table , then in the Grouping view , on the Row Groups side , select the parent group or the default row group and then in the Properties view under Group -> PageBreak set BreakLocation to None and PageName to the sheet's name .
The Rectangle method
The simplest and most reliable way I've found of achieving worksheets/page-breaks is with use of the rectangle tool.
Group your page within rectangles or a single rectangle that fills the page in a sub-report, as follows:
The quickest way I've found of placing the rectangle is to draw it around the objects you wish to place in the rectangle.
Right click and in the layout menu, send the rectangle to back.
Select all your objects and drag them slightly, but be sure they land in the same place they were. They will all now be in the rectangle.
In the rectangle properties you can set the page-break to occur at the start or end of the rectangle and name of the page can be based on an expression.
The worksheets will be named the same as the name of the page.
Duplicate names will have a number in brackets suffix.
Note: Ensure that the names are valid worksheet names.
You could use -sed- and -grep- to replace or write to the xml header of each file specifying your desired sheet name, e.g., sheetname1, between any occurrence of the tags:
<Sheetnames>?sheetname1?</Sheetnames>
While this usage of the PageName property on an object does in fact allow you to customize the exported sheet names in Excel, be warned that it can also update your report's namespace definitions, which could affect the ability to redeploy the report to your server.
I had a report that I applied this to within BIDS and it updated my namespace from 2008 to 2010. When I tried to publish the report to a 2008R2 report server, I got an error that the namespace was not valid and had to revert everything back. I am sure that my circumstance may be unique and perhaps this won't always happen, but I thought it worthy to post about. Once I found the problem, this page helped to revert the namespace back (There are tags that must also be removed in addition to resetting the namespace):
http://beatheadagainstwall.blogspot.com/2011/03/invalid-target-namespace-when-deploying.html?showComment=1440647962263#c5741523651495876761