How to rotate text in Excel spreadsheet cell using OpenXML and C# - c#

I'm trying to finish little application which is creating MS Excel spreadsheet filled with some data taken from a database. I got stucked with few things. One of these is how to rotate a text in a spreadsheet cell. I was trying to do it in that way:
SpreadsheetStyle style = SpreadsheetReader.GetDefaultStyle(spreadSheet);
style.AddAlignment(new Alignment() {
TextRotation = 90
});
but of course it didn't work. I'm using WorksheetWriter class to build excel doc.
I couldn't find anything helpful in Google so I hope to find some help here :)

Related

Inserting pictures using interop (C#) into powerpoint

can someone help me out?
I'm trying to insert pictures into powerpoint using this code:
PPT.Shape sheetShape = slides[slideIndex].Shapes[shapeName];
...
slides[slideIndex].Shapes.AddPicture(fileName, MsoTriState.msoFalse, MsoTriState.msoTrue, sheetShape.Left, sheetShape.Top, sheetShape.Height, sheetShape.Width);
my problem is, that it shifts the inserted picture like:
http://i.imgur.com/Ia2MVbk.png
So both have the same position but not really.
What am I doing wrong?
Thank you.
So because there is still no answer, I have to answer myself.
The problem with the charts I wanted to insert was, that they got rotated before (export from excel as image, then rotate) but powerpoint act like they are not rotated, so they have the wrong size and positiion.
But then I thought, there must be a possibility to rotate them in powerpoint, not before.
And thats it.
So I solved my problem with not exporting the charts from excel, but c&p them directly from excel and then rotate them in powerpoint.
Thats how it looks for me now:
chart.CopyPicture();
PPT.ShapeRange sr = slides[slideIndex].Shapes.PasteSpecial();
sr.Rotation = 90;
sr.Left = sheetShape.Left+30;
sr.Top = sheetShape.Top;
sr.Width = sheetShape.Width;
sr.Height = sheetShape.Height;
sheetShape.Delete();
Hope it helps if someone else got the problem.

Adding a note to a cell in Google Drive spreadsheet using C#

I'm currently working on a C# program to write a set of test results to a spreadsheet on Google Drive, and under the current format the cell to which I'm writing has one data value in the cell and the other 5 in a note (not a comment) on the cell.
EX: 1.8 visible in the cell, and when the cursor hovers over said cell, a small box appears to the side containing
Average: 1810 ms
Highest: 1921 ms
Lowest: 1708 ms
StdDev: 78 ms
Median: 1787 ms
My program currently can access and write to the cells in the Google spreadsheet, but I can't find a way to create a note for the cell and write to that. Any help is welcome.
If you take a look at this, setting a comment in the described way will actually add a note to the cell. This might be a known issue for them but I guess works in your favor. Hope this helps. :)

Inserting a striped line onto an Excel chart through COM Interop

How can we add a striped line to an Excel chart using C#?
I am able to create the chart using c# but I didn't get any clue how to add a striped line.
Please make some suggestions.
Thanks
Try this:
- add a data series with a steady value ( of 50 in your case )
- move the new data series to the secondary Y axis
- synchronize the maximum for both Y axes
- set Chart Type for the new data series to Line
- set the Line Style for the new data series to a dash type
I know this is not C#, but it is C# as much as you question is :)
When I have things like this, what I'm usually doing is I "manually" do all I have to do in Excel recording a macro with all the stuff. Then I just analyze the macro. You will find a lot of useful information there.
Good luck!

Create an Excel Line - Column combination chart in C#

I am trying to create an Excel line-column combination chart using C#.
I know how to create a line chart or a column chart but I don't know how to create a combined chart.
Could anyone please point me a direction or provide a short sample code on how to create such chart?
Thanks in advance.

Excel colours getting distorted when being copied from one template to another using VSTO(C#)

We are trying to generate an excel sheet using a template. Normally we would have done have a basic "Save As" to save the file but the file size came up to be too high. So, now we're working on copying the used range of the original workbook to a new workbook.
The data is getting copied, along with the validations and formulae on using the PasteSpecial command, and all data and formatting is the same, other than the cell background and the font colours. They have almost inverted.
Please suggest how could i solve this.
Excel use colors from a palette of 56 colors (may be more in Excel 2007/2010) that can be changed using Tools/Options/Color.
You can copy colors from one workbook to another using:
Workbook1.Colors = Workbook2.Colors
By copying the palette, you will of course affect the colors of all UI elements in the target workbook, not just the range you're copying.
It worked this way, the propety Workbook.Colors wasn't there. The foolowing statement did the job for me
wb2.set_Colors(Missing.Value, wb.get_Colors(Missing.Value));
Thank you for the replies everyone.

Categories

Resources