How can I vertically center a value in a PivotTable cell with Aspose Cells? - pivot-table

I know how to vertically center cell values when they can be defined by their row location, namely get a reference to them, create a style, assign values to the style, and then assign the style to the cell, like so:
cell = pivotTableSheet.Cells[4, 0];
cell.PutValue(AnnualContractProductsLabel);
style = cell.GetStyle();
style.HorizontalAlignment = TextAlignmentType.Center;
style.VerticalAlignment = TextAlignmentType.Center;
style.Font.IsBold = true;
pivotTableSheet.Cells.SetRowHeight(4, 25);
style.BackgroundColor = CONTRACT_ITEM_COLOR;
pivotTableSheet.Cells[4, 0].SetStyle(style);
But what about for recurring values, such as those that are generated for a PivotTable?
I create a row value like so:
pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Row, DESCRIPTION_COLUMN);
pivotTable.RowHeaderCaption = "Description";
...which appears like this (the values beneath "Description" such as "Anise, *" and "Artichokes, *", "Asparagus, *" etc.):
I want those values vertically centered, rather than at the top. How can I manage that?

If you do any formatting with the pivot table cell, then please create a Style object and then call this method. It should fix your issue.
mPivotTable.Format((2, 4, style);
Note: I am working as Developer Evangelist at Aspose

Related

Is it possible to add values to a ComboBox at different times?

I need to know whether it is possible to add values to a ComboBox at different times.
ObservableList<String> options1
= FXCollections.observableArrayList(
"Civil (CE)", "Computer (CT)", "Electrical (EEE)", "Electronics (ELS)",
"Mechanical (ME)");
comboBox1 = new ComboBox(options1);
comboBox1.setPrefSize(280, 30);
This is my code of ComboBox. In it I added 5 values at a time. But is it possible to add each value at different times, for example, add values one by one in a while loop. I tried it and the result was that each value overlapped previously added values, and as a result only one value was present in the ComboBox at the end. This the code with while loop -
while (rs.next()) {
subject = rs.getString("subname");
ObservableList<String> options1 = FXCollections.observableArrayList(subject);
comboBox1 = new ComboBox(options1);
}
Can I add values to ComboBox at different times, one after another, without overlapping the previous value ?
Yes, you can add/remove items at any moment using getItems()
comboBox1.getItems().add("Beer");
comboBox1.getItems().add("Whiskey");
comboBox1.getItems().add("Water");
or directly updating list:
options1.add("Milk");

OxyPlot : ColumnSeries/BarSeries display value of each column

In my WPF app, I use OxyPlot. I bind my data to the PlotModel and all is working well.
I want to display the value of each column on the chart. Is it possible?
For reference, this example of BarSeries on site, I wish to show actual value of Apples of 2009, 2010 & 2011 respectively on each column. i.e. value of Value1 for the 2009Apples column, Value2 for 2010Apples and so on.
I looked up at the APIof the BarSeries (For WPF ColumnSeries used interchangeably).
Tutorials of Bar & other plots. But couldn't find such thing anywhere.
How do I achieve this?
Yes, just set the LabelFormatString property of your series.
var theSeries = new ColumnSeries();
theSeries.LabelFormatString = "{0:F2}"; // Example: 1.2311 will display like "1.23"
// Add your columns
theSeries.Items.Add(new ColumnItem(someValue);
// ...
There is also an optional property you can set called LabelPlacement. The default value is LabelPlacement.Outside:
theSeries.LabelPlacement = LabelPlacement.Middle;

How to flex TextField in qooxdoo mobile

I'm trying to add a row on a qx.ui.mobile.page.NavigationPage consisting of a label, a text field, and a button. I want the text field to take up any extra horizontal space (the row should span the screen horizontally). I thought this would work:
var comp = new qx.ui.mobile.container.Composite();
comp.setLayout(new qx.ui.mobile.layout.HBox(null, 'middle'));
comp.add(new qx.ui.mobile.basic.Label("Filtering:"));
var f = new qx.ui.mobile.form.TextField();
comp.add(f, {flex:1});
var b = new qx.ui.mobile.form.Button("Update");
comp.add(b);
this.getContent().add(comp);
but it doesn't (see http://tinyurl.com/nwlhtwq for a playground example).
What am doing wrong? Thanks!
Have a look at this example:
http://tinyurl.com/nmw6lgs
It is because the textfield has a "display:inline-block" by default, and width of 100%.
Please set these properties:
qx.bom.element.Style.set(textField.getContentElement(),"display","block");
qx.bom.element.Style.set(textField.getContentElement(),"width","auto");
We will fix that in framework, too.

Array of Picture boxes - now showing pictures (Visual Basic)

So, I have an array of picture boxes
Dim LocationArray(8,6) As PictureBox
I have set the array to pictures boxes as so
ArrayLocation(0,0)=pic00
ArrayLocation(0,1)=pic01
ect.
So, when the form loads, I want the picture box (3,0) to load with a picture in it
So far I have
LocationArray(3,0).Image = My.Recources.pic
And nothing happens when I load the form.
When I try to display a picture after changing which the coordinates of the array, I get a NullreferenceExepecation error.
How will I be able to fix this, the code I have so far is,
Static xAxis As Integer = 3
Static yAxis As Integer = 0
LocationArray(xAxis, yAxis).Visible = False
xAxis = +1
LocationArray(xAxis, yAxis).Image = My.Resources.man
LocationArray(yAxis, xAxis).Visible = True

extjs - set grid column's width wide enough to display text in it

I am loading a grid dynamically in extjs. As you can see below the column "Created" is not wide enough to display whole text in it. I want to set every column's width such that it display's its text completely.
Is this possible to do? Any suggestion?
Thanks for help.
use parameter width: ... with your column config. As simple as this. I do not see your code so I am guessing.
However it look like you have more vertical space -> maybe break date in 2 lines (using template) would be solution, or you can have special css class just for this cell with smaller letter in order to fit.
Edit:
in your case it could be combination of defaultWith in ColumnModel (at least get 120 to fit your date, if more columns grid would adjust) and setColumnWith() dynamically based on length of data and number of columns - logic is up to you
Thanks bensiu, I implemented the login. However, I cannot say that this is the ideal solution but it solves my purpose.
First, i navigate through data and find the longest string in that column (including header name of that column).
// Store the longest string for each column in columns[col].maxstring
// Define a hidden label
{
xtype: 'label',
id: 'lblTab',
hidden: true
}
var lblTab = Ext.getCmp('lblTab');
var hiddenField = Ext.util.TextMetrics.createInstance(Ext.getCmp('lblTab').el);
var widthValue = 0;
// Iterate through each columns to set its maximum width
for(var col in columns) {
// find width of string
widthValue = hiddenField.getWidth(columns[col].maxstring);
// set column width
colModel.setColumnWidth(columns[col].index, widthValue + 20, false);
}
I hope this helps somebody.

Resources