When I run a query in MS Excel, and return the data to the worksheet, it always returns the data in font Helv 7. This format also affects the format of the row numbers & column headers. My default font/size is Calibri 11. I've looked all over and I can't seem to find any setups to change.
I looked at your workbook and the problem has nothing to do with Power Query. Any newly created sheet will have a font of Helvetica 7.
The problem is due to your "Normal" style which has been changed.
Right click on the Style box, select Modify; then Format; and change the font format to whatever you want for a new worksheet.
If you do this on the sheet that contains the query result, the font will change on that sheet (but not on other sheets that have previously been created).
Related
Is there any way to set style for all next cells in excel worksheet? Like for the rest of the document after certain cell?
I am using Apache POI 3.9 for exporting data to excel worksheet. Client wants colored font for invalid data. Everything is running fine, but sometimes, when I put text in empty cells in "INFORMATION" column, it makes font colored red, even after reseting cell style or explicitly asking for condition and then setting default cell style. Youre more likely to get my idea from pic of code.
Ive uploaded some pic of excel too. Hope it helps. It starts on row 37, text somehow changes color even after not running through setting conditions. I havent recognized any pattern in there.
I tried to change conditions, change cell style setting location in code... Had no effect.
Edit: It seems like the problem is not in AP but in Excel itself. It looks like the font color is changed after user input and its caused by autoformatting that is based on the context. So only option here is to change style of previous data. Could not find any other solution to this.
I am using OpenXML to create reports, I am filling data in existing excel template file.
In excel template 'Wrap text' for all cells is set to true. When my report is complete I open excel file.
In opened file cells are not sized correctly with text wrapping (text wrapping is not applied). Also I observed on machine with office 2007 it works cell are wrapped but on office 2013 cell are not correctly wrapped. If I just double click on any cell then entire row is correctly updated.
Can someone please help me in this, is any property \tag I can set in openXML so that on document open cells are correctly shown.
Previously we were using OLE office interface there it works always so expectation is it should work with openXML too.
Thanks,
Dhanaj
We have Excel 2013-2016 Add-in in C#. We use following method to get worksheet font:
var defaultFont = Microsoft.Office.Interop.Excel.Worksheet.Cells.Font
Everything worked until user changed font of some particular cell. For example user changed cell A1 and set font "Arial". By default we have font "Calibri".
Thereafter when we try to get default font by Worksheet.Cells.Font we get nothing - just empty object. I assume that because of ambiguity: A1 has font "Arial", other cells - default font "Calibri". My goal to get default font, i.e. "Calibri".
So far I re-write my code and now I check Styles too:
var workbookFont = Microsoft.Office.Interop.Excel.Worksheet.Parent.Styles["Normal"].Font;
This workaround returns exactly what I need - my "Calibri" font. But then I found , that's because this font is default for all new worksheets/workbooks (it can be setup in Options of Excel). It doesn't work if user selected all cells in worksheet and changed default font to "Times New Roman", then I would get "Calibri" - because this is default font will be used once new worksheet/workbook created. Again I faced issue when I can't get real default font for current worksheet. My next thought was to get font of some particular cell at the edge of worksheet that is not much usable for user like:
var defaultFont = workSheet.Cells[1048576][16384].Font
It looks pretty weird, but it works. My assumption that user doesn't use the last cell on a worksheet. (The 1048576 and 16384 are max size of worksheet ). I don't know implications of these method, so I'm wondering does it exist some "legal" way to get default font of worksheet , without such crutch ?
You were on the right path when using:
var workbookFont = Microsoft.Office.Interop.Excel.Worksheet.Parent.Styles["Normal"].Font;
The Normal style is the default font for a sheet, but the sheet might not actually have any instances of the default font (or the Normal style), or, all cells decorated with the Normal style may have had the font overridden on each cell format.
If a user applies their own fonts to various ranges, then the sheet will potentially have numerous fonts, and none of them are guaranteed to be the same as the font in the Normal style. The Font.Name might differ across a sheet, in which case Font.Name returns null, even though the Font.Size might be consistent (or if it isn't, then it too returns null).
When a user applies a custom font to a range that already has the Normal style, then the Style remains associated with the range, and the font overrides any font defined in the style.
Furthermore, it is common practice to select all the cells on the sheet when changing the font of the UsedRange (so that the row heights adjust proportionally), even if the UsedRange is only a small portion of all Cells.
So, you have to choose a font that is representative of the fonts that are used in the sheet, or apply fonts to new ranges as if they were Normal. That choice should be informed by what you know about the sheet, and what you intend to do with the font:
If you're inserting a column or row, then I'd suggest that you mimic Excel behavior and use the adjacent formats.
If you're adding a new range that is not adjacent to the UsedRange, then you will probably want to default to the Normal style.
If you're looking for a representative font of the UsedRange, you might want to avoid the first few rows and columns, as these tend to be headers, and the last rows can sometimes be totals. You'll need to loop over the cells in the range to find an appropriate cell format.
If you're reproducing the sheet content in some other format, then you'll need to inspect the font of each cell and every cell in the UsedRange.
The bottom-right-most cell is not necessarily any more or less similar to Normal or the fonts used in the UsedRange, so I'd advise against using it.
I know I can input an excel sheet into a ppt. But is it possible to allow a value in an earlier slide to be used within the ppt?
For example. Slide 3 has "expenses" but if you change some value on that page some cell value changes to reflect the new value on slide 3.
Try looking this page up. You can pick the appropriate office version. The proper approach would be using VBA.
https://msdn.microsoft.com/en-us/library/office/Ff746073.aspx
I am trying to use a VBA macro (for Office 2003) to do the following:
In Excel, the user will select a range of cells
In Word the user will call the macro (via a button or shortcut) to insert the selected Excel range as an embedded object
The code is not the problem so far, my problems are:
Given that the user is working in a Word document, most likely will use the same fonts in Excel
When Excel range was inserted in Word and they both use the same font names and sizes, they look different inside Word ( fonts look as if they stretched a bit)
Styling Cell borders in Excel is not like styling cell borders in Word
I do appreciate any advice on this regards
When you paste as an Excel Worksheet Object, what Word is actually displaying is an image created by Excel. Notice that you can't select any text, for example. Word appears to be distorting the image ever so slightly, so that the fonts won't line up.
Edit: I can't speak for Office 2003, but Office 2007 defaults to the HTML format using PasteExcelTable. The exact macro statement is
Selection.PasteExcelTable False, False, False
This will give formatting that is compatible with Word, but unfortunately the data is not live and won't get updated as the spreadsheet is changed. If your requirements don't include live update, try this method.
Is it possible to have the macro creating a table out of the cells (as normally happens when you manually copy them), rather than inserting an Excel Object.
The best visual results results can be achieved by using Selection.CopyPicture(Appearance, Format); however, you will not be able to edit the data inside Word as you will only get a picture.