Export to Excel alignment Issue

4 posts, 0 answers
  1. Srinivasan
    Srinivasan avatar
    2 posts
    Member since:
    Oct 2011

    Posted 19 Oct 2011 Link to this post

    Hi,
    When i export my grid to excel, the second column's content in the exported excel seems not to fit the column.
    I tried exporting the same grid to html and found that it is assigning a width of 20px for that column.

    Attached the image of an exported file. Please let me know how to fix this.


    Regards
    Srini
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 20 Oct 2011 Link to this post

    Hello Srinivasan,

    I was not able to reproduce such an issue at my end. Is there something special for that column? How are your columns and the RadGridView defined?

    I would be more helpful if I could reproduce this issue at my end. Could you please provide a detailed information about your scenario?

    Best wishes,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Srinivasan
    Srinivasan avatar
    2 posts
    Member since:
    Oct 2011

    Posted 20 Oct 2011 Link to this post

    Hi,

    In my developer machine it was exported fine. But in test server i have this problem.please find below the code i used,

    .xaml.cs
    String columnList = "LogDate,StudentName,Warning"; 
      
     PrintHelper.Export(StudentsGrid, columnList);-- Studentsgrid denotes grid name.
      
      
    .Xaml
      <telerikGrid:RadGridView x:Name="StudentsGrid" Grid.Row="4" VerticalAlignment="Stretch" Margin="0 0 0 0"
                                        ShowGroupPanel="False"
                                        CanUserFreezeColumns="False" RowIndicatorVisibility="Collapsed" 
                                        ItemsSource="{Binding AdmissionStudentCollection,Mode=TwoWay}" AutoGenerateColumns="False"
                                        CanUserDeleteRows="False"
                                        AlternateRowStyle="{StaticResource UxGridViewRowStyle1}"
                                        Style="{StaticResource UxRadGridViewStyle1}"
                                        HeaderRowStyle="{StaticResource UxGridViewHeaderRowStyle}" 
                                        RowStyle="{StaticResource UxGridViewRowStyle2}"                                             
                                        IsFilteringAllowed="False"
                                        CanUserReorderColumns="False"                                    
                                        GridLinesVisibility="None"
                                        CanUserResizeColumns="False"
                                        ShowColumnFooters="False" 
                                        BorderBrush="#9E9E9E"
                                        IsReadOnly="True"
                                        SelectionMode="Multiple"
                                        BorderThickness="1"                                                 
                                        ScrollViewer.VerticalScrollBarVisibility="Auto"                                            
                                        uc:ColumnHiderBinder.ColumnList="{Binding ColumnsToHide}">
                            <telerikGrid:RadGridView.Columns>
                                <telerikGrid:GridViewSelectColumn  UniqueName="GridViewSelectColumn" Width="10" HeaderCellStyle="{StaticResource UxGridViewHeaderCellStyle1}" />
      
                                <telerikGrid:GridViewDataColumn HeaderCellStyle="{StaticResource UxGridViewHeaderCellStyle1}" CellStyle="{StaticResource CustomCellStyle}" Header="Log Date" DataMemberBinding="{Binding LogDate}" UniqueName="LogDate" >
                                    <telerikGrid:GridViewDataColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding LogDate}" Style="{StaticResource G1TextBlockStyle_Content}" IsHitTestVisible="False" />
                                        </DataTemplate>
                                    </telerikGrid:GridViewDataColumn.CellTemplate>
                                </telerikGrid:GridViewDataColumn>
                                <telerikGrid:GridViewDataColumn DataMemberBinding="{Binding StudentName}" Header="StudentName" UniqueName="StudentName" HeaderCellStyle="{StaticResource UxGridViewHeaderCellStyle1}" CellStyle="{StaticResource UxGridViewCellStyleForC23}"/>
                                <telerikGrid:GridViewDataColumn Header="Student" DataMemberBinding="{Binding StudentNameSort}" UniqueName="Student" HeaderCellStyle="{StaticResource UxGridViewHeaderCellStyle1}" CellStyle="{StaticResource UxGridViewCellStyleForC23}">
                                    <telerikGrid:GridViewDataColumn.CellTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Vertical" Margin="2 0 2 0">
                                                <TextBlock Text="{Binding StudentName}" Style="{StaticResource G1TextBlockStyle_Content}"/>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="{Binding Gender}" Style="{StaticResource G1TextBlockStyle_Content}"/>
                                                    <Line X1="0" Y1="3" X2="0" Y2="13" Margin="5,0,5,0" Stroke="Black" StrokeThickness="1" VerticalAlignment="Center"/>
                                                    <TextBlock Text="{Binding DateOfBirth, Converter={StaticResource DateFormatConverter}}" Style="{StaticResource G1TextBlockStyle_Content}"/>
                                                </StackPanel>
                                            </StackPanel>
                                        </DataTemplate>
                                    </telerikGrid:GridViewDataColumn.CellTemplate>
                                </telerikGrid:GridViewDataColumn>
                                <telerikGrid:GridViewDataColumn HeaderCellStyle="{StaticResource UxGridViewHeaderCellStyle1}" CellStyle="{StaticResource CustomCellStyle}" Width="*" Header="Warning" DataMemberBinding="{Binding WarningMsg}" UniqueName="Warning">
                                    <telerikGrid:GridViewDataColumn.CellTemplate>
                                        <DataTemplate>
                                            <Grid>
                                                <TextBlock Text="{Binding WarningMsg}" Style="{StaticResource G1TextBlockStyle_Content}" TextWrapping="Wrap" />
                                            </Grid>
                                        </DataTemplate>
                                    </telerikGrid:GridViewDataColumn.CellTemplate>
                                </telerikGrid:GridViewDataColumn>
                            </telerikGrid:RadGridView.Columns>
                        </telerikGrid:RadGridView>


  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 21 Oct 2011 Link to this post

    Hello Srinivasan,

    If the GridView is in the VisualTree, then there should not be such a problem. I see that the other 2 columns have a CellTemplate defined. What about to define a CellTemplate for that column as well?

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top