从 SSRS 导出时如何获取命名的 Excel 工作表

发布于 2024-07-17 19:27:14 字数 355 浏览 8 评论 0 原文

每当将单页报表导出到 Excel 时,Excel 中的工作表均以报表名称命名。 如果报表有多个页面,则工作表将命名为sheet1、sheet2、.... 有没有办法在 SSRS 2005 中指定工作表名称?

解决方案: 经过一些谷歌搜索后发现了这个: 更改 SQL Server RS Excel 中的工作表名称:QnD XSLT

将尝试并发布更新(如果有效)。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

堇色安年 2024-07-24 19:27:14

死灵术,以防万一所有链接都变暗:

  1. 将群组添加到您的报告
    另外,建议在此处设置组表达式的排序顺序,以便选项卡将按字母顺序排序(或者您希望的排序方式)。

    1. 添加向您的报告小组

    • “Zeilengruppe”的意思是“目标群体”
    • “Gruppeneigenschaften”是指“集团财产”
  2. 在组属性中设置分页符
    2. 设置组属性中的分页符

    • “Seitenumbruche”的意思是“分页符”
    • “Zwischen den einzelnen Instanzen einer Gruppe”的意思是“组的各个实例之间”
  3. 现在您需要设置 成员(组)的 >PageNameNOT Tablix 本身PageName
    如果您获得了正确的对象,则属性网格的标题框中会显示“Tablix Member”(德语为 Tablix-Element)。 如果它是错误的对象,它会在属性网格的标题框中显示only“table/tablix”(没有member)。

  4. 注意:如果您获取 tablix 而不是 tablix 成员,它会在每个选项卡中放置相同的选项卡名称,后跟 (tabNum)! 如果发生这种情况,您现在知道问题是什么了。
    Tablix 会员

MultiTabExcelFile

Necromancing, just in case all the links go dark:

  1. 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).

    1. Add a group to your report

    • 'Zeilengruppe' means 'Target group'
    • 'Gruppeneigenschaften' means 'Group properties'
  2. Set the page break in the group properties
    2. 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'
  3. 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.

  4. 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.
    Tablix Member

MultiTabExcelFile

孤星 2024-07-24 19:27:14

要导出到不同的工作表并使用自定义名称,从 SQL Server 2008 R2 开始,可以使用分组、分页符和组的 PageName 属性的组合来完成此操作。

或者,如果您只想为单个工作表指定特定名称,请尝试使用报表上的 InitialPageName 属性。

有关更详细的说明,请查看此处:http://blog.hoegaerden.be/2011/03/23/where-the-sheets-have-a-name-ssrs-excel-export/

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/

一杆小烟枪 2024-07-24 19:27:14

在 SSRS 2008 R2 中使用页面组的 PageName 属性:

长伴 2024-07-24 19:27:14

为了在导出到 Excel 时添加选项卡名称,我使用了以下方法:

  • 在报表设计窗口中,选择 tablix 对象。
  • 打开 Tablix 对象的属性窗口。
  • 将所需的选项卡名称添加到 PageName 属性中。
  • 运行报告
  • 将报告导出到 Excel。
  • 现在,工作表名称与 tablix 对象的 PageName 属性相同。

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.
明明#如月 2024-07-24 19:27:14

将选项卡名称放在报表中的页眉或组 TableRow1 上,以便它将显示在每个 Excel 工作表上的“A1”位置。 然后在 Excel 工作簿中运行此宏。

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

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
灯下孤影 2024-07-24 19:27:14

没有直接的方法。 您可以导出 XML,然后修改 XSLT 以正确格式化它(这是一种困难的方法)。 一种更简单的方法是编写多个没有显式分页符的报告,以便每个报告仅在 Excel 中导出到一张工作表中,然后编写一个可以为您合并的脚本。 无论哪种方式,都需要后处理步骤。

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.

[旋木] 2024-07-24 19:27:14

我能够按照 Valentino Vranken 和 rao 建议的更复杂的说明完成此操作,但这里有一个更简单的方法,用于更简单的报告。 这会将每个表放在单独的工作表上并在 Excel 中命名它们。 它似乎对 PDF 和 Word 等其他导出没有影响。

首先,在表格的 Tablix Properties 中的 General 下,选中 在之前或之后添加分页符,这会将报表分隔成工作表。

然后在每个表中,单击该表,然后在分组视图中的行组一侧,选择父组或默认行组,然后在 Group -> 下的 >Properties 视图 PageBreakBreakLocation 设置为 None,并将 PageName 设置为工作表的名称。

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 .

梦情居士 2024-07-24 19:27:14

矩形方法

我发现实现工作表/分页符的最简单、最可靠的方法是使用矩形工具。

将页面分组到矩形或填充子报表中的页面的单个矩形内,如下所示:

  • 我发现放置矩形的最快方法是将其绘制在您希望放置在矩形中的对象周围.

  • 右键单击并在布局菜单中将矩形置于底层。

  • 选择所有对象并稍微拖动它们,但确保它们落在原来的位置。 现在它们都将位于矩形中。

在矩形属性中,您可以将分页符设置为发生在矩形的开头或结尾,并且页面的名称可以基于表达式。

工作表的名称将与页面的名称相同。

重复的名称将在后缀括号中包含一个数字。

注意:确保名称是有效的工作表名称。

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.

夏见 2024-07-24 19:27:14

您可以使用 -sed- 和 -grep- 替换或写入每个文件的 xml 标头,指定所需的工作表名称,例如,sheetname1,在任何出现的标签之间:

<Sheetnames>?sheetname1?</Sheetnames>

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>
南城旧梦 2024-07-24 19:27:14

虽然在对象上使用 PageName 属性实际上允许您自定义 Excel 中导出的工作表名称,但请注意,它还可以更新报表的命名空间定义,这可能会影响将报表重新部署到服务器的能力。

我有一份报告,我在 BIDS 中应用了此方法,并将我的命名空间从 2008 年更新到了 2010 年。当我尝试将报告发布到 2008R2 报告服务器时,我收到一个错误,指出命名空间无效,必须将所有内容恢复回来。 我确信我的情况可能是独一无二的,也许这不会总是发生,但我认为值得发帖。 一旦我发现问题,此页面帮助恢复命名空间(除了重置命名空间之外,还必须删除一些标签):

http://beatheadagainstwall.blogspot.com/2011/03/invalid-target-namespace-when-deploying.html? showComment=1440647962263#c5741523651495876761

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文