How to Choose Fields While Using ExportToExcel in jqGrid ?

Posted by João Guilherme on Stack Overflow See other posts from Stack Overflow or by João Guilherme
Published on 2010-01-18T22:39:51Z Indexed on 2010/06/10 5:02 UTC
Read the original article Hit count: 644

Filed under:
|
|

Hi ! I have this jqGrid

<trirand:JQGrid runat="server" ID="JQGrid1" OnRowEditing="JQGrid1_RowEditing" 
    RenderingMode="Optimized" oncellbinding="JQGrid1_CellBinding" Height="350" EditUrl="/Ferramenta/Transacoes/TransacoesT.aspx">
    <AppearanceSettings HighlightRowsOnHover="true"/>
    <Columns>
        <trirand:JQGridColumn DataField="IdLancamento" PrimaryKey="True" Visible="false" />
        <trirand:JQGridColumn DataField="IdCategoria" Visible="false" />
        <trirand:JQGridColumn DataField="DataLancamento" Editable="true" DataFormatString="{0:dd/MM/yy}" HeaderText="Data" Width="65" TextAlign="Center" CssClass="font_data" />
        <trirand:JQGridColumn DataField="Descricao" Editable="true" HeaderText="Descrição" Width="330" />
        <trirand:JQGridColumn DataField="NomeCategoria" Editable="true" EditType="DropDown" EditorControlID="ddlCategorias" HeaderText="Categoria">
            <Formatter>
                <trirand:CustomFormatter FormatFunction="DefineUrl" />
            </Formatter>
        </trirand:JQGridColumn>                
        <trirand:JQGridColumn DataField="Valor" Editable="false" DataFormatString="{0:C}" HeaderText="Valor" Width="80" TextAlign="Center" />
    </Columns>
    <ClientSideEvents RowSelect="editRow" />
    <PagerSettings PageSize="20" />
    <ToolBarSettings ShowEditButton="false" ShowRefreshButton="True" ShowAddButton="false"
        ShowDeleteButton="false" ShowSearchButton="false" />
    <SortSettings InitialSortColumn=""></SortSettings>
</trirand:JQGrid>
<asp:LinkButton ID="lbExportar" runat="server" onclick="lbExportar_Click">Exportar todas as transações</asp:LinkButton>

When I use the method ExportToExcel

JQGrid1.ExportToExcel("export.xls");

it includes the first column IdLancamento that is not visible and also includes another column that is used on the query. Is it possible to choose the columns that are going to be exported ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET