I have a Scenario to print UsedRange area From Spreadsheetgear For that i have used below statement
workbookView.ActiveWorksheet.UsedRange.Select();
Using above statement i got like below
and after that Print works Fine. As soon as this goes for print then i want to Dselect that UsedRange.
Means i want like below
How to do this?
You can move the selected cell back to the first cell in the sheet (or any other cell for that matter) after the print code has run using the Activate() method which will deselect the selected cells:
workbookView.ActiveWorksheet.Cells["A1"].Activate();
The API documentation here states To set the active cell, use the IRange.Activate() method.
I don't think it's possible to have no cell selected so it could be worth storing the selected range before you select the entire contents then after the print re-select the previously selected range with the above code.
Related
I am using Aspose. Cell for .net to write some data into Excel. I have a quick question:
what are the best practices to get and write a value into the below cell?
this kind of cell may be across multiple columns/rows, does it belong to Rang or a special cell?
thanks
If it is merged cell, then you should use Cell object (you may use its PutValue method to insert data). Please note, in MS Excel sheet, when you merge a range of cells, the merged cell’s name will be top left cell,
so it will be accessed by that name. For example, when you merge "B1:F3" cells, it will become one big cell (B1). Now you got to access and insert data into B1 cell if you want to insert some data into that merged area range.
PS. I am working as Support developer/ Evangelist at Aspose.
I'm writing a program in C# that accesses the Excel Interop interface to create a spreadsheet. My program creates a worksheet, then enters some text into the first row. I want to set the font to bold for the first row, as a title, but things aren't working as expected.
First I create a range object for the row, then I set the BOLD attribute
Range rng1 = ws.Rows[1];
rng1.Style.Font.Bold = true;
This works OK and afterwards I have a bold header line. However, I noticed that the rest of the spreadsheet was getting set to bold also. So I added some code to turn it OFF but it didn't work as expected. The code looks like this:
Range rng2 = ws.Rows[rownum];
rng2.Style.Font.Bold = false;
The "rownum" variable starts at 2 and increments through 12. It's never set to 1. So this should be creating a second range object that has zero overlap with the first one. Yet for some reason, this turns off the bold attribute for everything.
It seems like the entire spreadsheet is affected by turning BOLD on or off. Oh, and I can do these steps in any order.
Any ideas what's going on and how to fix it?
guys!
After I create Excel document in my c# application the Ctrl+DownArrow combination doesn't work properly.
It goes to the last row in the current column. So looks like it means all sheet as one data region WITHOUT empty cells.
so I guess empty cells in my excel sheet aren't empty for Excel.
How to figure it out?
Thank you,
Try creating a macro of what you want to happen. Then look at the macro code which is based off of interops calls. See if it sheds a light on your issue and how to resolve.
Just filter out the "Blanks" Ctrl+Down Arrow and all the blank cells would be selected, now press delete (From key board).
DONE. Now you can jump between entries with Ctrl+Down Arrow.
I'm trying to do an Excel Add-In and I would like that, in a worksheet that I'm creating, I could select a cell (or a range of cell) that, once you start typing on it (or them), a dropdown-like with possible matches for the typed characters.
Is this possible to do it programmatically?
The closest that I got to achieve this is through the Validation object of the Cell, but a dropdown-like list of options is not displayed just, as you could imagine, I get to display a message indicating that the text is not valid.
As always, thanks in advance!
I have a datagridview on the Windows Form in c#. I am updating and filling the table adapter on the cell event. The problem is that When I go to lower half of the datagrid which is not visible until I scroll down, as I click any cell, the table adapter is filled and updated and the pointerpoints to the very first row.
Any suggestion on how to fix it. I have a ideas to record the top row of the datagridview that is visible and set the pointer to that row. But how to do it?
Before the fill happens, save the current cell:
DataGridViewCell selectedCell = dgv.CurrentCell;
Then after the fill, set it back:
dgv.CurrentCell = selectedCell;
If you don't care which cell was selected but just want to scroll the view back to where it was before the fill, you can use the FirstDisplayedCell property instead.
I believe these will work but I haven't used them in your exact scenario (which sounds kinda funky).
Incidentally, there a lot of events on the DataGridView, which gives great flexibility, but you have to read the docs carefully to understand all your options.