This is a migrated thread and some comments may be shown as answers.

Radgrid export to ExcelML currency issue

9 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vasya Ivanov
Top achievements
Rank 1
Vasya Ivanov asked on 23 Apr 2010, 03:08 PM
Hello,
I have a problem with exporting Radgrid to ExcelML.My Radgrid consist of 6 column,three of these column are Service Hours,Service Mins and PaidAmount.
When

ExcelMLExportStylesCreated event fired I have following code:

 

 

 

if (style.Id == "itemStyle")

 

{

style.NumberFormat.FormatType = Telerik.Web.UI.GridExcelBuilder.

NumberFormatType.Currency;

 

style.AlignmentElement.HorizontalAlignment = Telerik.Web.UI.GridExcelBuilder.

HorizontalAlignmentType.Left;

 

style.InteriorStyle.Color = System.Drawing.

Color.WhiteSmoke;

 

style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.

InteriorPatternType.Solid;

 

}

 

else if (style.Id == "alternatingItemStyle")

 

{

style.NumberFormat.FormatType = Telerik.Web.UI.GridExcelBuilder.

NumberFormatType.Currency;

 

style.AlignmentElement.HorizontalAlignment = Telerik.Web.UI.GridExcelBuilder.

HorizontalAlignmentType.Left;

 

style.InteriorStyle.Color = System.Drawing.

Color.LightGray;

 

style.InteriorStyle.Pattern = Telerik.Web.UI.GridExcelBuilder.

InteriorPatternType.Solid;

 

}
When the currency is set,its applied to every column which contain number including ServiceHours and ServiceMins.I need that curency applied only to PaidAmount column.But if I comment out style currency format,PaidAmount column trailing zero cuts off and no dollar sign appeared.
Please help me.Thanks

9 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 23 Apr 2010, 05:06 PM
Hello Vasya,

You can set your own custom style to the PaidAmount column.
protected void RadGrid1_ExcelMLExportRowCreated(object source, GridExportExcelMLRowCreatedArgs e)
{
   e.Row.Cells.GetCellByName("PaidAmount").StyleValue = "myCustomStyle";
}

protected void RadGrid1_ExcelMLExportStylesCreated(object source, GridExportExcelMLStyleCreatedArgs e)
{
   StyleElement myStyle = new StyleElement("myCustomStyle");
   myStyle.NumberFormat.FormatType = NumberFormatType.Currency;
   ...
   e.Styles.Add(myStyle);
}

For more information please examine the following link:
ExcelML export

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Vasya Ivanov
Top achievements
Rank 1
answered on 23 Apr 2010, 08:49 PM
Thanks Daniel,
it work when you export a regular Radgrid to excel,but when I do grouping and after that try to export to excelML I am getting error:

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 498:        protected void JobDetailGrid_ExcelMLExportRowCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs e)
Line 499:        {
Line 500: e.Row.Cells.GetCellByName("PAYAMOUNT").StyleValue = "myPaystyle";Line 501:        }
Line 502:

Source File: C:\EISPortal1\EISPortal\EISPortal\Controls\BulkJobControl.ascx.cs    Line: 500

Thanks again for your help.
0
Daniel
Telerik team
answered on 23 Apr 2010, 09:58 PM
Hello Vasya,

Please try to modify your code this way:
protected void JobDetailGrid_ExcelMLExportRowCreated(object source, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs e)
{
    if (e.RowType == GridExportExcelMLRowType.DataRow)
    {
         e.Row.Cells.GetCellByName("PAYAMOUNT").StyleValue = "myPaystyle"
    }
}

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Vasya Ivanov
Top achievements
Rank 1
answered on 23 Apr 2010, 10:32 PM
Hello again Daniel,
it worked.Thanks so much for your help.Since I am new to Telerik if you dont mind I asked another question.
In my radgrid when I do grouping data in expand group then I export to excel and when excel is opened data in collapse group.
Maybe ExcelML not support expand group?
Thanks again


0
Daniel
Telerik team
answered on 26 Apr 2010, 09:53 PM
Hello Vasya,

I'm not sure that I understand your question completely. As per my understanding, your groups collapse when exporting. If so, could you please post your code here so I can examine it?

Best regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Vasya Ivanov
Top achievements
Rank 1
answered on 26 Apr 2010, 10:25 PM
Hi Daniel,
sorry if I wasn't clear.Here is a code for grouping:

protected

 

void JobDetailGrid_GroupsChanging(object source, GridGroupsChangingEventArgs e)

 

{

 

if (e.Action == GridGroupsChangingAction.Group)

 

{

 

if (e.Expression.GroupByFields[0].FieldName == "LOCATION")

 

{

 

 

GridGroupByField amountGroupField = new GridGroupByField();

 

 

GridGroupByField locGroupField = new GridGroupByField();

 

 

GridGroupByField hrsField = new GridGroupByField();

 

 

GridGroupByField minsField = new GridGroupByField();

 

locGroupField.FieldName =

"Location";

 

locGroupField.HeaderText =

"Loc";

 

hrsField.FieldName =

"HRS";

 

hrsField.HeaderText =

"Hr";

 

hrsField.Aggregate =

GridAggregateFunction.Sum;

 

minsField.FieldName =

"MINS";

 

minsField.HeaderText =

"Mns";

 

minsField.Aggregate =

GridAggregateFunction.Sum;

 

amountGroupField.FieldName =

"PAYAMOUNT";

 

amountGroupField.HeaderText =

"Pd";

 

amountGroupField.Aggregate =

GridAggregateFunction.Sum;

 

 

e.Expression.SelectFields.Clear();

e.Expression.SelectFields.Add(locGroupField);

e.Expression.SelectFields.Add(hrsField);

e.Expression.SelectFields.Add(minsField);

e.Expression.SelectFields.Add(amountGroupField);

 

 

//e.Expression.GroupByFields.Clear();

 

 

//e.Expression.GroupByFields.Add(amountGroupField);

 

}

 

}

}


When I do grouping by location I see radgrid like this:

Loc: 12X271; Hr: 23; Mns: 710; Pd: 1392.68 (Showing 10 of 24 items. Group continues on the next page.)


After that I click export to excel button and instead of seeing exaclty like this in excel which is in expand mode I see spreadsheet like this:
Pri CheckNumber Location EvntCode EarnDate ServiceHrs ServiceMins ServicePers RsnCode PayAm
Loc: 12X271; Hr: 23; Mns: 710; Pd: 1392.68; Loc: 12X271;
0866182 P54319101 12X271 1/2/2008 1 41 0 $67.30
0866182 P54319101 12X271 1/3/2008 1 31 0 $60.64
0866182 P54319101 12X271 1/4/2008 1 23 0 $55.31
0866182 P54319101 12X271 1/7/2008 1 28 0 $58.64
0866182 P54319101 12X271 1/8/2008 1 19 0 $52.64
Should be display like this on excel spreadsheet:
+ Loc: 12X271; Hr: 23; Mns: 710; Pd: 1392.68  and when I click + it should collapse.

Thanks so much for your help.
0
Daniel
Telerik team
answered on 30 Apr 2010, 08:29 AM
Hello Vasya,

RadGrid exports the group structures but doesn't support Microsoft Excel's grouping.

Let me know if you need more information.

Best regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Vasya Ivanov
Top achievements
Rank 1
answered on 30 Apr 2010, 05:24 PM
Thanks Daniel,
Now I have another problem.I try to use Ajax to dipslay progress bar while user hit search button  or retrieve another grid.
I have two radgrid.First grid displayed afer search button is clicked and the second grid is displayed when click row on the first grid.
Keep in mind that I am using the following code in user control:

<

 

telerik:RadScriptManager ID="ScriptManager1" runat="server" />

 

 

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" >

 

 

 

<AjaxSettings>

 

 

 

<telerik:AjaxSetting AjaxControlID="JobReportGrid">

 

 

<UpdatedControls>

 

 

<telerik:AjaxUpdatedControl ControlID="JobReportGrid" LoadingPanelID="RadAjaxLoadingPanel1" />

 

 

</UpdatedControls>

 

 

</telerik:AjaxSetting>

 

 

<telerik:AjaxSetting AjaxControlID="JobDetailGrid">

 

 

<UpdatedControls>

 

 

<telerik:AjaxUpdatedControl ControlID="JobDetailGrid" LoadingPanelID="RadAjaxLoadingPanel1" />

 

 

</UpdatedControls>

 

 

</telerik:AjaxSetting>

 

 

</AjaxSettings>

 

 

</telerik:RadAjaxManager>

 

 

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" IsSticky="false" runat="server">

 

 

</telerik:RadAjaxLoadingPanel>

 


When I entered search criteria and click search button progress bar does not work.When first grid displayed and I choose a row and click it,progress bar is working but data on the second grid not displayed, I know for sure data exist in the second grid.
When I comment out above coding the data is displayed on the second grid but I need progress bar.
Please help me resolve that issue.

Thanks
0
Daniel
Telerik team
answered on 06 May 2010, 10:34 AM
Hello Vasya,

Please stick to these threads if you need further assistance about the RadAjaxLoadingPanel:
Progress bar while radgrid is loading
Progress bar indicator problem

Thank you for your understanding.

Regards,
Daniel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Vasya Ivanov
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Vasya Ivanov
Top achievements
Rank 1
Share this question
or