How to display a specific Excel Range in c# - c#

For a little windows application, I need to display a specific range of a worksheet into a container of my WPF window. This range contains shapes and also notes that have to de displayed too.
This app takes a folder of many excel files with the same format. After choosing the folder, the user selects the file and the part of the file (Part One, Part two ...) The parts don't correspond to rows or columns, it is like "D28:AA39". The selection works well, selection of range too but once my Range is selected I don't know how to display it. Datagrid doesn't seem to display shapes and notes.
The app is supposed to be used on a small screen and with a device with not awesome specs so displaying in a new Excel file isn't a viable solution. The final result is to display the range in my C# window with all the data. Those data doesn't need to be alterable, they just need to be readable. Thanks a lot for helping me.

So I figured out myself how to do it the "simplest" way.
To make this opration i just used the [Range].CopyPicture() which allow you to copy the range as a picture in the clipboard.
Then you save this into as a temporary file and once it is done you just have to display an Image in a container.
Hope it will help other people.

Related

Plotting data in c#, with a user interface

I am in the process of writing a program in c# (I am using c# because it's a language that I want to learn now), and I want the following features :
plot data from a .csv file, which will look something like the picture
in particular I want to be able to chose the font of the labels, color of dots, etc.
once the data is plotted from the csv file, have an interface that will allow small adjustments, for example move a label around, or add a line between chosen dots
be able to export a pdf out of the chart (or potentially more charts).
So I am creating a Windows application Form which would provide the interface, load the .csv file and parse it. This is fine.
I was wondering what experimented people would suggest for creating the chart and be able to manipulate it (the small interface that I was mentioning above). I saw the chart class of c#, would that be enough ? In particular, would that allow me to interact with the chart, and change my labels ?
Any recommendation is appreciated, thank you!

Embed office 2010 excel file in a c# Winform Application

I have spent the last 2 hours researching how to embed an excel file along with its formulas for a few cells and display it in a Winform application so the user can enter values and also the c#app can modify cell values based on some other resource data that is fed in via a USB port.
I cannot find any method other than these two - the first isn't supported and the other is 16 years old. Is this possible / supported to embed an excel sheet in a c# application?
Please note, I do not want to open the excel sheet and copy the data into a datagrid or similar as i need to use excel's functionality of conditional formulas to turn cells green if certain criteria are met etc etc the list of excel benefits goes on here. There are hundreds of these conditional formatting and embedded upper/lower limits in an existing excel file and i just want to embed the file and use excel's already excellent functionality.
Method 1 DSOFramer - No longer supported
Method 2 https://www.codeproject.com/Articles/15760/How-to-Integrate-Excel-in-a-Windows-Form-Applicati
using interop.excel with c# you can open excel, show it, interact with it using events to capture cell entry and cell change. its not embedded in the form but the end result is the same.

How can I create an Excel sheet view for user input in C#?

I wanted to create a view that is the same as an Excel sheet of some rows and some columns in which user can give inputs and it should grow dynamically but some cell should be filled by program internally and should be read only. I am making an windows form application using C#. Is there any way to do it in C#?
There are several tools to aid you in doing this task. Telerik and Infragistics are 2 of them.
http://www.telerik.com/
http://blogs.telerik.com/aspnet-ajax/posts/13-07-30/create-excel-asp-net-grid
http://www.infragistics.com/products/windows-forms/infragistics-excel/
This article may be useful too.
http://support.microsoft.com/default.aspx?scid=kb;EN-US;304662

EXcel VSTO - Transferring a list object onto a worksheet

I have a VSTO add in I am looking to implement.
I would like to click a button and a list of products, names, etc would be placed onto the worksheet.
I understand that I could go through each individual item in the list and then write this cell by cell, but is there a way of literally just 'dumping' the data onto the worksheet?
Apologies if this is a really thick question.
Nope, there is no easy way to just 'dump' the data. You're going to have to do it the hard way. Just google for some examples, it's easy enough.
http://www.google.nl/search?q=c%23+export+data+to+excel
That depends on where your "list of products, names, etc" are coming from. If those items are fixed, you can create a template document with a prepared worksheet containing these items. Put this document into an embedded resource of your program. When you want to create a new worksheet from this template, extract your resource to a temporary file and use the Excel API to copy the worksheet from your template to your working document.
Sounds perhaps more complicated than it is. Here
Read a file from a resource and write it to disk in C#
you find an example how to accomplish the "extract file from resource to temporary file" part.

importing excel data while retaining formatting

Is it possible to import excel data to display using C# in any view(data grid etc ..) while retaining formatting like Bold, italic and strikethrough, throughout the document? I am making a Windows form application. My data is in an excel sheet, I want to display it in grid view or any other while retaining the formatting.
Well, there are some ways that I can think of but neither of them are very pretty at all and they would not be very effecient.
1) Parse the excel file cell by cell using Excel Interop. (Very nasty)
2) If you can convert the excel file to Excel XML you could then write say a XSLT to parse the file to pull styling data much more quickly.
Of course getting the styling data out is one thing. Applying it can be a whole other experience. Once you get the styling you have to make sure you apply the values to all the correct columns. Again very nasty and alot of parsing.
However since you did not say whether this was a web or desktop app you could always just embedd an excel control (on the web side) to display the data which may solve your problem. On a desktop app you are probably in for a world of pain trying to do what I describe above.
Maybe somebody will have a better answer but that's what I got.
SpreadsheetGear for .NET can load Excel workbooks and provides access to formatted text values as well as cell formatting such as fonts and colors.
SpreadsheetGear also comes with a Windows Forms spreadsheet control which will allow users to display, edit, format, calculate, print, etc... workbooks with formatting, charts, etc... intact.
If you are building an ASP.NET application, you can use SpreadsheetGear to open a workbook and generate an image of cells and / or charts as shown on our "Excel Chart and Range Imaging Samples" page here
You can download the free trial here if you want to try it out.
Disclaimer: I own SpreadsheetGear LLC

Categories

Resources