I am having issues where data getting exported to an XLSX file where some tabs are not getting the data. FileExportMode is set to FileExportMode.NewSheetInExistingFile and the file is not in use. The weird part, is I can run the code multiple times and each time, it is different tabs that don't get populated. In the end, I should end up with 14 tabs and I get those 14 tabs, the only thing that is in the tabs, is the headers. if I export that data for each tabs individual to their own file, the data is there and exported as expected. Maybe I am missing something?
Another weird part, is when I watch the file exporting (in window explorer), you can see the file go to 0KB. It is really weird
Here is my export code
List<Tuple<int, string, bool>> jurisdictionTypes =
new JurisdictionTypeDA().GetJurisdictionTypeKeyValueList();
foreach (Tuple<int, string, bool> jurisdictionType in jurisdictionTypes)
{
RadPivotGrid tempPivotExportGrid = new RadPivotGrid
{
ColumnGrandTotalsPosition = TotalsPos.None,
ColumnsSubTotalsPosition = TotalsPos.None,
EmptyValueString = "0",
RowGrandTotalsPosition = TotalsPos.None,
RowsSubTotalsPosition = TotalsPos.None
};
var exportResults = _apportionmentInfoPivot
.Where(app => app.JurisdictionTypeKey == jurisdictionType.Item1
.OrderBy(app => app.PartySort)
.ThenBy(app => app.LegacyKeyValue)
.Select(app => new
{
jurisdiction_name = app.JurisdictionName?.Trim() ?? string.Empty,
party_name = app.PartyName?.Trim() ?? string.Empty,
totalvoters = app.TotalVoters,
signaturesneeded = app.SignaturesNeeded
})
.ToList();
tempPivotExportGrid.DataSource = exportResults;
tempPivotExportGrid.RowGroupDescriptions.Clear();
tempPivotExportGrid.ColumnGroupDescriptions.Clear();
tempPivotExportGrid.AggregateDescriptions.Clear();
// Row Information
PropertyGroupDescription myRows = new PropertyGroupDescription
{
PropertyName = "jurisdiction_name",
CustomName = "Jurisdiction",
SortOrder = Telerik.Pivot.Core.SortOrder.None
};
tempPivotExportGrid.RowGroupDescriptions.Add(myRows);
// Column Information
PropertyGroupDescription myCols = new PropertyGroupDescription
{
PropertyName = "party_name",
CustomName = "Party",
SortOrder = Telerik.Pivot.Core.SortOrder.None
};
tempPivotExportGrid.ColumnGroupDescriptions.Add(myCols);
// Aggregate Information
tempPivotExportGrid.AggregateDescriptions.Add(new PropertyAggregateDescription()
{
PropertyName = "totalvoters",
CustomName = "Count",
AggregateFunction = AggregateFunctions.Sum,
StringFormat = "#,##0"
});
tempPivotExportGrid.AggregateDescriptions.Add(new PropertyAggregateDescription()
{
PropertyName = "signaturesneeded",
CustomName = "Needed",
AggregateFunction = AggregateFunctions.Sum,
StringFormat = "#,##0"
});
tempPivotExportGrid.AggregatesPosition = PivotAxis.Columns;
// Combine each result into a new tab
PivotGridSpreadExport spreadExport = new PivotGridSpreadExport(tempPivotExportGrid)
{
SheetName = jurisdictionType.Item2,
FileExportMode = FileExportMode.NewSheetInExistingFile
};
spreadExport.RunExport(myExportFile, new SpreadExportRenderer());
// Send each result to their own sheet
PivotGridSpreadExport mySpreadExport2 = new PivotGridSpreadExport(tempPivotExportGrid)
{
SheetName = jurisdictionType.Item2,
FileExportMode = FileExportMode.CreateOrOverrideFile
};
string newfile = string.Concat(Path.Combine(Path.GetDirectoryName(myExportFile) ?? string.Empty, Path.GetFileNameWithoutExtension(myExportFile)), "_", jurisdictionType.Item2, Path.GetExtension(myExportFile));
mySpreadExport2.RunExport(newfile, new SpreadExportRenderer());
}
Due to the nature of the data, I can't share the results, so I will try to re-create this in a temp project.
I have attached a like to a video, you can see at 4 seconds and 9 seconds, the file is emptied (0 KB).
https://app.screencast.com/6SjZNCAoooWUh
TIA for any help here.
Probably more of a suggestion than a question.
I would like an FileExportMode that is between the 2 existing modes. It creates or overrides the named Sheet in the given XLSX
User could then:
I would like to know how to access the values that are typed in all the "Value Filter" and "Label Filter" options, which appear in the PivotGrid filters in the RowGroupDescriptions and ColumnGroupDescriptions parts, since I require those values to perform additional calculations.
I have tried to reach the values but I only reach the Type of condition and the value, I provide the code that I use for what I mention:
foreach (PropertyGroupDescriptionBase gd in this.radPivotGrid1.RowGroupDescriptions)
{
ValueGroupFilter Filtroporvalor = gd.GroupFilter as ValueGroupFilter;
if (Filtroporvalor.Condition != null)
{
ComparisonCondition condition = Filtroporvalor.Condition as ComparisonCondition;
var condicionaux = condition.Condition;
var valorthan = condition.Than;
switch (condicionaux.ToString())
{
case "Equals":
//Code that performs additional calculations
break;
case "IsGreaterThan":
//Code that performs additional calculations
break;
case "IsDoesNotEqual":
//Code that performs additional calculations
break;
}
}
}
But I cannot reach the other values, for example if I use "Equals", I would also like to obtain the name of the field that is used to perform that condition and so on for the other options of "Value Filter", that field is the one that is you can select in the window that is displayed when the filter is applied:
Thank you for your support.
I know how to sort column chooser for RadGridview:
e.ColumnChooser.SortOrder = RadSortOrder.Ascending
is there a way to sort Field Chooser for RadPivotGrid too?
Hi, good morning.
I am using a Pivotgrid, PivotFieldList and Chartview.
The chartview graphs whatever the Pivotgrid has, but there are times when the Pivotgrid has too many records and the Chartview takes a long time to generate.
As seen in the documentation, a Chartview takes time, because it is recalculating the points to regenerate the graph, after having created it previously.
This has led me to think that if instead of the Chartview graphing the Pivotgrid, it would better graph a DataTable.
My idea is the following:
I already generated a filtered DataTable, the result of the interaction between the Pivotgrid and the PivotFieldList and that DataTable fills the Chartview to generate the graph, I think it would take less time to create the graph, since each time the filtered DataTable would be created.
I was looking at this example that you provide to create a graph from a datatable:
https://www.telerik.com/forums/use-radgridview-as-a-datasource-for-radchartview
But it does not graph as expected, that is, it does not show the graphs the same as when the pivotgrid is filled.
Is it possible to do this, or even if you do, will the graph creation time be the same? Because if so, there is no point in working on this solution.
Thank you very much for your attention.
Hello good afternoon.
I ask for your support, for the following.
In a graph, when there are many elements in X, the labels come together a lot and the text is not understood.
When I apply a configuration by code, the graph does look better:
horizontalAxis.MajorTickInterval = 10;
horizontalAxis.TickLength = 10;
horizontalAxis.TickWidth = 10;
I would like to start from the number of elements on the X axis that the labels begin to join, to automatically apply the aforementioned code.
Hi,
I have a pivotgrid table like this:
true | vegetables | data | data | data
| fruit | data | data | data
| subtotal | data | data | data
----------------------------------------------------
false | vegetables | data | data | data
| fruit | data | data | data
| subtotal | data | data | data
How can i change the row header (true, false that are boolean values) using specifically cellformating?
Hello,
I am trying to export a radPivotGrid into excel as per the documentation
private void radButton1_Click(object sender, EventArgs e)
{
SaveFileDialog sf = new SaveFileDialog();
sf.Filter = "EXCEL | .xls";
if (sf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
// Telerik.WinControls.UI.Export.ExportToExcelML htmlexport = new Telerik.WinControls.UI.Export.ExportToExcelML(radPivotGrid_StockPositionPivot);
// htmlexport.RunExport(sf.FileName);
PivotGridSpreadExport spreadExport = new PivotGridSpreadExport(radPivotGrid_StockPositionPivot);
spreadExport.RunExport(@"..\..\exported-file.xlsx", new SpreadExportRenderer());
}
}
the red marked position is throwing an exception, and code suggestion is asking to create a new class to implement SpreadExortRenderer I am not sure how it can be done, any help will be appreciated. TIA
I have a Pivot Grid, that has a data set that has two fields, In those fields, it's possible that records in that collection could have empty string value. And if I set one field to be my column group and the other to be my row group and one of those fields as my aggregate count field, everything looks fine, and as expected.
However, as soon as I filter the ROW GROUP other than the EMPTY value, it drops the COLUMN groups "EMPTY" string column, as well, as if I filter the COLUMN GROUP on a non-empty value, it removes the ROW GROUP's empty string row. I am not sure if this is by design or what but, this is causing an issue for our customers as they cannot figure out why their numbers in this pivot grid are not the same in other reports (non-pivot). NOTE, if I filter in either the GROUP or COLUMN fields for the "EMPTY" string value, all the EMPTY string values still show in the COLUMN/ROW groups.
As a solution to this problem, I made sure that these "EMPTY" string fields has at least one empty space in them... Attached is my sample project. Once you run the form, just filter either the ROW or COLUMN group on anything other than the EMPTY string value.
Thanks
Hello,
I am working on the development of an application and I have some doubts in the handling of the PivotFieldList control.
I would like to know how to enter the onclick event of the "Update" button of the PivotFieldList, I want to place some validations when clicking on that button.
I would also like to know how to access the onclick event of the "OK" button that appears in each filter of the fields that are displayed in the PivotGrid, because I also want to add some validations when the button is clicked.
Thanks for the support.