4 Answers, 1 is accepted
Hi Chuck,
Please check out the following articles that describe the specifics and different ways of formatting the PDF/Excel output.
If the desired appearance or formatting is beyond the built-in capabilities of the RadGrid, then usually the DocumentProcessing Libraries come to assistance:
- For Integration between RadGrid and the RadPdfProccessing - the one responsible for creating, importing and exporting PDF documents, check out Customize content when Exporting RadGrid to PDF
- RadGrid and RadSpreadProcessing - used for creating, importing and exporting XLSX, CSV and TXT documents, check out Integration with Telerik Document Processing Library
If these articles are not helping to solve the issue. It would be beneficial if you provide us a sample code representing a concrete scenario so that we have a better overview and advise you best.
Looking forward to hearing from you!
Kind regards,
Doncho
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.
Hi Chuck,
I have made a quick test and the padding-left does seem to work. Also, I have tested the text-align which did work too.
Result of the 20px padding
Result of the text-align center
Here is the code I used for testing
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="800px" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemDataBound="RadGrid1_ItemDataBound" GridLines="Both">
<MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID" CommandItemDisplay="Top">
<CommandItemSettings ShowExportToPdfButton="true" />
<Columns>
<telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32"
FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn DataField="OrderDate" DataType="System.DateTime"
FilterControlAltText="Filter OrderDate column" HeaderText="OrderDate"
SortExpression="OrderDate" UniqueName="OrderDate">
</telerik:GridDateTimeColumn>
<telerik:GridNumericColumn DataField="Freight" DataType="System.Decimal"
FilterControlAltText="Filter Freight column" HeaderText="Freight"
SortExpression="Freight" UniqueName="Freight">
</telerik:GridNumericColumn>
<telerik:GridBoundColumn DataField="ShipName"
FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
SortExpression="ShipName" UniqueName="ShipName">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ShipCountry"
FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
SortExpression="ShipCountry" UniqueName="ShipCountry">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = OrdersTable();
}
private DataTable OrdersTable()
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("OrderID", typeof(int)));
dt.Columns.Add(new DataColumn("OrderDate", typeof(DateTime)));
dt.Columns.Add(new DataColumn("Freight", typeof(decimal)));
dt.Columns.Add(new DataColumn("ShipName", typeof(string)));
dt.Columns.Add(new DataColumn("ShipCountry", typeof(string)));
dt.PrimaryKey = new DataColumn[] { dt.Columns["OrderID"] };
for (int i = 0; i < 70; i++)
{
int index = i + 1;
DataRow row = dt.NewRow();
row["OrderID"] = index;
row["OrderDate"] = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).AddHours(index);
row["Freight"] = index * 0.1 + index * 0.01;
row["ShipName"] = "Name " + index;
row["ShipCountry"] = "Country " + index;
dt.Rows.Add(row);
}
return dt;
}
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
var item = e.Item as GridDataItem;
foreach (GridTableCell cell in item.Cells)
{
//cell.Style.Add("padding-left", "20px"); // works
cell.Style.Add("text-align", "center"); // works
}
}
}
Kind regards,
Attila Antal
Progress Telerik
Our thoughts here at Progress are with those affected by the outbreak.