I'm attemping to update an Excel 2007 pivot table in VSTO (C#) and would like to ensure that the pivot table doesn't get updated until all of my edits are done. So there's a property on the PivotTable class, ManualUpdate, that apparently does exactly what I want. Unfortunately it appears that often times when I assign it the value "true" the value doesn't change. Additionally, I've also seen on other occassions where it will change from "true" to "false" by itself.
BTW, I'm working with an OLAP cube. Does anyone know what the issue/conditions I need to consider with PivotTable.ManualUpdate?
Thanks!
Related
I'm trying to create an extended gridview class that will enable me to always have a footerrow that can be used to add data. That's the end goal.
I've tried classes that were found elsewhere on stackoverflow, but the code I found is apparently buggy (it either works when the footerrow is the only row, or it works when the footerrow is not the only row, but never both. Possibly related to the fact that I have dropdownlists in my rows). This problem was explained here: Bizarre issue with customized gridview control
The class itself is also problematic, in that the formatting is kind of messed up when the footerrow is the only row. It just doesn't look right... the color formatting is gone.
So now I'm thinking what I really want to do, is rewrite the data sources so they're based on UNION queries, so that there's always one blank row with -1 in the key column (my tables always have single incremental primary keys, so no legit row will ever have -1 in the key column), and then have a class that automatically hides any row where the value in the "DataKeyNames" field is -1.
Problem: I have no idea how to do this. :) I know how to do it in the aspx.cs code (RowDataBound event -- if(condition) {e.Row.Visible = false;}), and I know how to do it via CSS, but I don't know how to do it automatically in an extended class. I'm afraid I'm a little lost when it comes to writing extended classes.
To sum up, what I'd like to do is put an extended gridview class in my aspx code, set the usual gridview things, and have the only additional thing in my code be an added "UNION SELECT" in my datasource, and have it just automatically hide the row that the UNION SELECT provided, so that there's always at least one row in the gridview (thereby taking care of the entire footerrow not showing up problem), without me having to code anything extra in a RowDataBound event every time, because I have these gridview controls EVERYWHERE in my code.
Many thanks for any help you can provide! :)
I've been playing around with this, but I just can't get it to work. I have a table in Microsoft Word, and in this table is a mailmerge field which my C# program selects.
I'd like to delete the row which contains the field. I tried this:
app.Selection.SelectRow();
app.Selection.Delete();
Where app is an instance Microsoft.Office.Interop.Word.Application.
As written, this code deletes the text inside the table, but leaves an empty table row behind. How can I delete the table row itself?
When you have a Range or Selection, in most cases you can address the "containing" level like this:
app.Selection.Rows[1]
(Since I'm on a mobile device I can't check whether you can use .Delete() directly or whether you need .Range.Delete())
Similarly, Selection.Tables[1] would pick up the table around the selection and Selection.Paragraphs[1] the paragraph around the selection.
Note that, unless what you want to do simply won't work any other way, you should use the Range object. There will be less screen-flicker, execution will be faster and your code more predictable.
Given a data set containing multiple rows, from within a .NET console application I need to generate a report on a single page for each row, sending those pages directly to the printer.
I am attempting to use Microsoft Report for this by attaching it to a data set and placing TextBoxes where I wish. Generating the report and sending it to the printer are not a problem. Unfortunately, the data only seems to be available in aggregates -- First, Sum, Last, Max, etc. I cannot latch the text box to a bare field.
Some poking around here and other sites seems to address this, but only when the data is presented in a table. One post even said without elaboration, "My mistake was using Text Boxes"
Am I using the wrong tool for what I am attempting to accomplish?
I ran into the same problem and managed to solve it. The solution seems a little convoluted to me so don't quote me on the "right" way to do this, but here is what I did:
Make sure you have a Dataset defined for your report.
Add a "Table" control to the report. This seems to be needed in order to iterate the rows in your Dataset.
Delete the header row and two of the default columns from the table so that you are left with a single row with a single column.
Expand the table to the width of your layout and make it as tall as you will need for your "free form" layout.
By default, there is a TextBox inside the table cell. Right-click the empty table cell and choose "delete" to remove that TextBox.
Drag a "Rectangle" control into the empty table cell. It seems to automatically "dock" to the width/height of the table cell.
Now you should be able to drag the fields from your DataSet (TextBoxes, etc) into the Rectangle to produce the desired layout.
Note that I am in the early stages of using this approach so I'm not sure if I am going to hit any walls... but for a basic report that uses TextBoxes and a page break after each "row" it seems to be working ok.
Or you try to use a list.
In the list you can arange textboxes (and other controls) as you want and they will be filled for each record in the recordset.
This work for me. :-)
I have a DevExpress WPF grid (version 9.3). When I export to excel, it has horrible additional rows* that completely mess up excel's functionality such as auto filter.
I've been trying to make sense of the documentation and I think that the solution may lie in setting TableView.PrintCellStyle somehow. But it's really not clear.
I am using the TableView.ExportToXls(string path); method.
Is there a quick way of switching off this behaviour and getting a working xls file?
*I understand that this is to help with creating a spreadsheet that looks the same as the grid. Horrible default behaviour - a working spreadsheet is more important than it looking like the UI.
EDIT: #DmitryG - I have tried this and now, instead of three lines I now get two. Better, but not solved.
I have also checked the KB article you cited and get the following result:
I am using version 9.3.6.
Anything else I can try?
EDIT 2: Have tried the value converter approach. Getting the same additional row.
Worst case, is there anyway of excluding these columns from the export?
As far as I can see the problem like yours was already discussed here:
Exporting Boolean Values causes Three Merged Rows To Appear for each Row of data.
The problem solution for version 9.3 was the direct assigning of the GridColumn.EditSettings property:
<dxg:GridColumn x:Name="Boolean" FieldName="Boolean">
<dxg:GridColumn.EditSettings>
<dxe:CheckEditSettings HorizontalContentAlignment="Center"/>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
Please also review the following KB article:
How to change representation of data cells via PrintCellStyle when printing/exporting grid data.
P.S. This problem is absent in the latest versions.
DevExpress has significantly improved the export engine in the latest version 14.2 and now the issue should be solved.
Please refer to the following help article for more information:
Printing and Exporting
I was still getting the additional rows. The quickest and easiest way to get around this was to set the EditSettings of the column so it exports 'True' or 'False', export the grid then set the column back to a checkbox.
Thusly:
public void ExportGridToExcel()
{
TableView.Grid.Columns["*FieldName*"].EditSettings = new TextEditSettings();
TableView.ExportToXls(#"C:\temp\spreadsheet.xls");
TableView.Grid.Columns["*FieldName*"].EditSettings = new CheckEditSettings();
}
NB It's the fieldname the column is bound to and NOT the column name. That caught me out for a minute.
I'm in C# Express 2010 and SQL Server Express 2008, making a winforms front end for simple table editing. User picks a table from a combobox, and a datagridview is populated with that table. There's a Submit and Reload button at the bottom of the form. It's loosely based on Microsoft's example for binding a DGV to a database.
So, I have this datagridview that is populated by a data adaptor. After it's been populated, I go through the resulting table and replace any columns with foreign keys with comboboxcolumns so it's easier for the user.
This bit all works fine. The comboboxcolumn shows up, with the correct data in it etc etc. I've set the Headertext, DataProprtyName, and Name properties to match the column it has replaced.
It DOES seem to have broken my 'submit' button that does the update command. Basically, if I change the value in one of the comboboxcolumns, I get a concurrency violation. If I change a value in any other column, it silently fails (when the data is reloaded into the DGV, the updated value vanishes).
Any ideas what the problem could be here?
If you need to see code just let me know. There's rather a lot of it as I'm a newbie and have probably done things in a horrendously messy way!
Thanks in advance.
Never mind - I figured it out - I had copy/pasted a procedure and forgotten to create a new DataAdaptor, so it was using the same one as the one used to populate the DGV, hence things went A over T...