RadGrid 导出到 Excel 布局问题
所以我有一个带有 MasterTableView 的网格,其中包含一个 DetailTable,并且该 DetailTable 包含一个 DetailTable。就布局缩进而言,当它渲染到屏幕上以及导出到 pdf 时,一切都是正确的。但问题是当我尝试导出到 Excel 时。当电子表格打开时,MasterTableView 项目的宽度为 7 列。第一个 DetailTable 项目的宽度为 5 列,第二个 DetailTable 项目的宽度为 3 列。它们看起来像是中心对齐的,所以看起来像一个颠倒的金字塔。我的客户不喜欢这个,我已经尝试了几个小时来弄清楚如何使项目缩进看起来像 pdf 和屏幕中的那样,但没有成功。是否有设置或其他东西可以使 Excel 正确渲染,或者这是一个错误。下面是我的网格标记,我将附上电子表格的图像,以便您可以看到它的样子。感谢您对此问题的任何帮助。
<telerik:RadGrid ID="RadGrid1" runat="server" ShowFooter="false" AutoGenerateColumns="false"
AllowPaging="true" AllowSorting="false" CellSpacing="5" AllowFilteringByColumn="false">
<ExportSettings HideStructureColumns="true" ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
<Pdf AllowAdd="false" AllowCopy="true" AllowModify="false" AllowPrinting="true" PageTitle="ESign Sent vs Sold"
Title="ESign Sent vs Sold" PaperSize="A4" PageWidth="260mm" />
<Excel Format="Html" />
</ExportSettings>
<ClientSettings AllowExpandCollapse="true">
<Selecting AllowRowSelect="true" />
</ClientSettings>
<MasterTableView DataKeyNames="ParentID, ID" Name="DivisionTable" HierarchyLoadMode="Client" HierarchyDefaultExpanded="false" ClientDataKeyNames="ParentID, ID">
<HeaderStyle Font-Bold="true" HorizontalAlign="Left" Wrap="false" />
<ItemStyle Wrap="false" VerticalAlign="Middle" HorizontalAlign="Left" />
<AlternatingItemStyle Wrap="false" VerticalAlign="Middle" HorizontalAlign="Left" />
<FooterStyle Wrap="false" />
<DetailTables>
<telerik:GridTableView Name="RegionTable" DataKeyNames="ParentID, ID" ClientDataKeyNames="ParentID, ID" HierarchyLoadMode="Client" Width="100%" HierarchyDefaultExpanded="false" >
<DetailTables>
<telerik:GridTableView Name="BranchTable" DataKeyNames="ParentID, ID" ClientDataKeyNames="ParentID, ID" HierarchyLoadMode="Client" Width="100%" HierarchyDefaultExpanded="false" >
<Columns>
<telerik:GridTemplateColumn UniqueName="Filler" ItemStyle-Width="25px" HeaderStyle-Width="25px">
<ItemTemplate>
<span> </span>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn UniqueName="Text" DataField="Text" SortExpression="Text" HeaderText="Branch" ItemStyle-Width="300px" HeaderStyle-Width="300px" />
<telerik:GridBoundColumn UniqueName="SentCount" DataField="SentCount" SortExpression="SentCount" HeaderText="ESign Sent" ItemStyle-Width="150px" HeaderStyle-Width="150px" />
<telerik:GridBoundColumn UniqueName="SoldCount" DataField="SoldCount" SortExpression="SoldCount" HeaderText="Sold w/ ESign" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridBoundColumn UniqueName="Text" DataField="Text" SortExpression="Text" HeaderText="Region" ItemStyle-Width="300px" HeaderStyle-Width="300px" />
<telerik:GridBoundColumn UniqueName="SentCount" DataField="SentCount" SortExpression="SentCount" HeaderText="ESign Sent" ItemStyle-Width="150px" HeaderStyle-Width="150px" />
<telerik:GridBoundColumn UniqueName="SoldCount" DataField="SoldCount" SortExpression="SoldCount" HeaderText="Sold w/ ESign" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridBoundColumn UniqueName="Text" DataField="Text" SortExpression="Text" HeaderText="Division" ItemStyle-Width="300px" HeaderStyle-Width="300px" />
<telerik:GridBoundColumn UniqueName="SentCount" DataField="SentCount" SortExpression="SentCount" HeaderText="ESign Sent" ItemStyle-Width="150px" HeaderStyle-Width="150px" />
<telerik:GridBoundColumn UniqueName="SoldCount" DataField="SoldCount" SortExpression="SoldCount" HeaderText="Sold w/ ESign" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
So I have a Grid with a MasterTableView that contains a DetailTable, and that DetailTable contains a DetailTable. Everything is correct as far as layout indentation when it renders to the screen and when I export to pdf. But the problem is when I try to export to excel. When the spreadsheet opens the MasterTableView item is say 7 columns wide. The first DetailTable item is say 5 columns wide, and the second DetailTable items are 3 columns wide. And they appear like they are center aligned so it looks like an upside down pyramid. My client does not like this and I have tried for hours now to figure out how to make the item indentations look like they do in the pdf and screen but with no luck. Is there a setting or something to make the excel render correctly or is this a bug. Below will be my grid markup, and I'll attach an image of the spreadsheet so you can see what it looks like. Thanks for any help in this issue.
<telerik:RadGrid ID="RadGrid1" runat="server" ShowFooter="false" AutoGenerateColumns="false"
AllowPaging="true" AllowSorting="false" CellSpacing="5" AllowFilteringByColumn="false">
<ExportSettings HideStructureColumns="true" ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
<Pdf AllowAdd="false" AllowCopy="true" AllowModify="false" AllowPrinting="true" PageTitle="ESign Sent vs Sold"
Title="ESign Sent vs Sold" PaperSize="A4" PageWidth="260mm" />
<Excel Format="Html" />
</ExportSettings>
<ClientSettings AllowExpandCollapse="true">
<Selecting AllowRowSelect="true" />
</ClientSettings>
<MasterTableView DataKeyNames="ParentID, ID" Name="DivisionTable" HierarchyLoadMode="Client" HierarchyDefaultExpanded="false" ClientDataKeyNames="ParentID, ID">
<HeaderStyle Font-Bold="true" HorizontalAlign="Left" Wrap="false" />
<ItemStyle Wrap="false" VerticalAlign="Middle" HorizontalAlign="Left" />
<AlternatingItemStyle Wrap="false" VerticalAlign="Middle" HorizontalAlign="Left" />
<FooterStyle Wrap="false" />
<DetailTables>
<telerik:GridTableView Name="RegionTable" DataKeyNames="ParentID, ID" ClientDataKeyNames="ParentID, ID" HierarchyLoadMode="Client" Width="100%" HierarchyDefaultExpanded="false" >
<DetailTables>
<telerik:GridTableView Name="BranchTable" DataKeyNames="ParentID, ID" ClientDataKeyNames="ParentID, ID" HierarchyLoadMode="Client" Width="100%" HierarchyDefaultExpanded="false" >
<Columns>
<telerik:GridTemplateColumn UniqueName="Filler" ItemStyle-Width="25px" HeaderStyle-Width="25px">
<ItemTemplate>
<span> </span>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn UniqueName="Text" DataField="Text" SortExpression="Text" HeaderText="Branch" ItemStyle-Width="300px" HeaderStyle-Width="300px" />
<telerik:GridBoundColumn UniqueName="SentCount" DataField="SentCount" SortExpression="SentCount" HeaderText="ESign Sent" ItemStyle-Width="150px" HeaderStyle-Width="150px" />
<telerik:GridBoundColumn UniqueName="SoldCount" DataField="SoldCount" SortExpression="SoldCount" HeaderText="Sold w/ ESign" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridBoundColumn UniqueName="Text" DataField="Text" SortExpression="Text" HeaderText="Region" ItemStyle-Width="300px" HeaderStyle-Width="300px" />
<telerik:GridBoundColumn UniqueName="SentCount" DataField="SentCount" SortExpression="SentCount" HeaderText="ESign Sent" ItemStyle-Width="150px" HeaderStyle-Width="150px" />
<telerik:GridBoundColumn UniqueName="SoldCount" DataField="SoldCount" SortExpression="SoldCount" HeaderText="Sold w/ ESign" />
</Columns>
</telerik:GridTableView>
</DetailTables>
<Columns>
<telerik:GridBoundColumn UniqueName="Text" DataField="Text" SortExpression="Text" HeaderText="Division" ItemStyle-Width="300px" HeaderStyle-Width="300px" />
<telerik:GridBoundColumn UniqueName="SentCount" DataField="SentCount" SortExpression="SentCount" HeaderText="ESign Sent" ItemStyle-Width="150px" HeaderStyle-Width="150px" />
<telerik:GridBoundColumn UniqueName="SoldCount" DataField="SoldCount" SortExpression="SoldCount" HeaderText="Sold w/ ESign" />
</Columns>
</MasterTableView>
</telerik:RadGrid>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,内置的 Excel 导出功能并不可靠。
将导出按钮添加到您的页面,然后尝试使用此按钮:
Yea, the built in Excel export functionality is unreliable.
Add an export button to your page, and try using this instead: