I want to update various charts on openxml Powerpoint file using openxml sdk 2.
I have managed to update the data on the excel sheet that feeds the chart and the chart itself. but that's not very efficient because i end up doing the same thing twice (updating the embedded excel and the chart object with the same data) and also because the chart object's xml structure is different for different chart types, so more should-be-unnecessary code and probably more bugs.
I wonder if there is a way to tell the Chart to update itself with the new data on the excel.
I also tried to use the AutoUpdate property of the chart but without any results. This is a follow up question. The first one was this one: How to make a powerpoint chart reflect changes to its data source?
To my knowledge, what you are looking for (frustrating as it is) is not possible.
I've been in the exact same position with word documents, and ended up doing a method for each type of chart I knew my code would encounter.
I don't believe there is a trigger for you to force an update upon opening word.
But I would love to be proved wrong.
Editing to clarify.
Yes, you can update the charts by only updating the data-caches in xml and not the embedded parts, however, you then end up with a word document in which, if you double click a chart to vidw the data-source, you'll get another data-source than the one shown in the document. Further more, when you close the data-source (the embedded excel) the chart will update to the values from the embedding.
In short. Unless you intend to PDF your document or something like that, it is advicable to update both the embeddings and the xml-charts.
Related
I have a list of pulse values at a certain time and I want to build a chart from this data
In the screenshot is an example what I want
At the moment I am able to create an xlsx file and write values to cells, but how to create a chart from this data? I use the NPOI library
I attach a link to github with the function code of creating an xlsx file, filling cells and basic chart
Using the Jason example, I was able to build such a simple chart.
However, there are questions about his appearance
Is it possible for a diagram to make a title?
Also, I would like to designate the axis titles
In the example there is a title of the series, which I would like to remove, if it is not specified, then it is created automatically, if you make the name empty, then there will be only a strip on the side, which reduces the whole chart, how to get rid of the title of the series?
There is also a question whether it is possible to use data from another page for a chart
I also found out that the document does not open, when I try to use "double" in the diagram, I don’t know the reason for this error
I have an excel sheet with a complex formula applied in it. I want to use this formula from my C# code for some calculations. My scenario is like this User fill a form (web) and submit, our program will fetch these values and applied in the hosted excel sheet and get the result.
is this possible?
Help is highly appreciable.
Thanks,
This really should go in the comments section, as I have a few questions to clarify your request. However, as I do not yet have the reputation, my questions must go here.
Is it a formula residing in your existing Excel document that you want to utilize that formula/document without re-writing the code?
Or are you asking if it is possible to write the same formula that you have working on the Excel sheet in c#?
If the former, it is conceivable to pass data into the Excel sheet from the code. After all we can use code to append to other document types, why not an Excel document? And if we can fetch specific lines from other document types, why not from an Excel document (especially since the grid/cell layout provides easier addressable points). However, while it is conceivable, doesn't mean it's easy. It's an interesting proposition, and I'd like to do some experiments on that.
If it is the latter, then depending on the formula's requirements, you may just need to use the appropriate math libraries and write out the formula directly in the c# code. You may not be able to visually see how everything ties together as nicely in the Excel document (with the referenced cells highlighted), but you could modularize components of the formula more easily as sub-functions and re-use values easily enough with variables.
Hello I have a chart that I need to have the system review and give results...
Chart image located here....
example chart .pdf http://imageshack.us/photo/my-images/651/scorecardchartexample.gif/
http://imageshack.us/photo/my-images/651/scorecardchartexample.gif/
--Assume the chart is in .PDF and the text is renderable I.E. "highlight-able".
--Assume the chart is placed on the page exactly the same way and same position every time
--Assume the chart can change - that is to say, I need to be able to upload a 1000 of these charts all following the exact same format but with some alternate info from chart to chart.
--Assume VAST expertise in .NET - and little expertise in actual text interpretation.
--Assume expertise in interpreting .PDF that have editable fields...I am already doing this, this is limited to .PDF's I created and was able to place values on each field etc.
--Assume this chart is only deliverable in a single text renderable .PDF - that is to say - we interact with a website that creates this chart - this website has no API to interact with, we must print to PDF this chart from the webpage and that is all we can do...(government website)
Using a .NET system, I need to create a program...or incorporate an existing application into my .NET system, that will review this chart and will be able to tell what each "X" represents...that is to say an "X" one inch to the left or in the next row is an indicator of a different result (refer to chart)
I need the program to perform its search and return results based on the trigger of the .PDF document hitting a folder or whatever. This part we can handle assuming we creating the program from scratch...otherwise we will be limited to interacting with an existing app as needed.
We are open to a variety of strategies. Assuming such a class or object exists, we were thinking of reading text based on location in the document, like an X,Y sort of thing. Another desireable route would be some sort of stringBuffer (assume C#) but will need to be able to navigate the chart gridlines and will need to count white spaces to accurately interpret the position of the "X"'s and what the "X" means based on its placement. 3rd option, something we are unware of.
If something exists and is tried and true, well that of course woould be best. Then any tips on interfacing with it using .NET and C#.
Thank you all very much in advance Code Gawds!
Reel
OK We found some software called ClearImage - it wasn't cheap but it is pretty neat. It will analyze any image in the same fashion Adobe PDF analyzes a document to find form fields. After clear image does that it gives you a list of "blobs" you then get to dictate what each blob means and give it a unique identifer. This allows for auto value declaration based on "blob" placement in the image.
It also allows to sort of "finger print" an image so if the same image were to show up it could recognize it...in my case we have 3 different templates for the chart, and indeed each one will be different due to different charting, but ultimately each template has the same layout from multiples of the chart...this has helped in allowing our system to identfy what chart has been entered then after that first check, move on to anyalizing each blob.
Anyway, worth a look if anyone else should come across this question and is in need this type of function. I didn't want to leave it unanswered. I may update this as we learn more about it. I know this isn't exactly a coding question but this type of task is coding intensive and if anyone was looking to perform the same task they may find their way here. I will endeavor to update in the spirit of stackoverflow with comments relating to integration and objects etc. etc.
should anyone have more questions about this software in relation to coding you can ask here or post a new question, we will be happy to post our code (methods, classes objects etc.) we used (in C#) in terms of integrating it into our/your programs.
Good Morning,
I have a C# agent which runs periodically and updates certain values in a particularly important spreadsheet, the reason that this spreadsheet is updated is that periodically someone will manually go into this .xls file and print screen the worksheets and paste them in to a Powerpoint presentation template as images.
These 'images' aren't charts, nor tables, simply ranges of cells that are coloured etc in the spreadsheet - and what I'm looking to do is basically automate this by customising my agent so that everytime it updates the spreadsheet, it 'print screens' a certain range that I specify and copies it as an image into the .ppt file.
I appreciate this question lacks a code example, and I'm not expecting someone to 'do it for me', any advice or pointers on how I might accomplish this would be much appreciated.
Also VSTO is not an option unfortunately (work environment).
Many Thanks
You may not have the ability to control how other people create their PowerPoint slides, but if they want a specific range of cells to update to match what the excel sheet is currently, they can Ctrl-C the section then Paste Special.
I know your question asked about automating a print screen capture of the cell range, but would this work for you? Or must there be no possibility of an accidental update, or some reason it must be an image?
The linked section will automatically update if the file is open and if it isn't it will ask if you want to update the links on opening the PowerPoint. Or right-click on the object in the slide and update link.
I've been doing it too reccently.
It might give you an idea.
Put an Alternative.Text to your shape in PowerPoint, it might help you place your new image in the correct place.
C# Paste HTML to Excel or PowerPoint
Showing HTML in PowerPoint
I am required to produce a somewhat complicated excel workbook containing over 30 worksheets, each using information from several database tables to dynamically draw several tables per sheet, with formating. I have used c# in the past although I am unfamilar with its use in Excel. Any recomendations regarding to how to format and posistion cells dynamically from a database would be a great help.
Thanks in advance.
Visual Studio Tools for Office (VSTO) is your friend :) I use this all the time to build complex worksheets. This is way, way better than importing from CSV or using some kind of wacky DB connectivity.
Here are some links
MSDN
Blog
Wikipedia
This is very easy to do, though there are a few oddities. I find it very effective to use the Excell MACRO recorder to record actions, then look at the source and re-impliment in C#. The object model is exactly the same between VB and C#.
VSTO is part of Visual Studio 2008. I looked on the product page, but I cannot determine if it comes with VS2008 C# Express Edition. The easiest thin to do is just download it and see :)
Your question sounds like you already understand the technology involved, so this answer is restricted to formatting & layout.
I did something very similar 10 years ago. It's been a while, but here's what I figured out.
Put all calculated & summary info on top. (including 'bottom line' totals)
Base charts on the totaled cells at the top of the sheets since they don't move.
Put all charts, summaries, etc on their own sheet.
If there are calculations involved, make each step of the process available so the user can step through them. This will prevent you spending countless hours proving your code calculates according to spec, if you don't do this, your 'black box' calculations will be questioned constantly.
If they don't want to see the raw data, only the calculations, then consider pushing it out to a hidden sheet.
Store a template workbook with your app, then just copy it so you can do all formatting in XL, not code.
One thing you really want to avoid is keeping track of different cell locations. You want to push values into cells which are always in the same location.
I find a very effective and often underused feature in Excel is the Web Query.
If you can present your data in a website, you can pre-build your Excel workbook with web queries set up to gather the data from the website on demand, which is presented in the form of tables in appropriate web pages.
You can add query string parameters for passing arguments to the web page and you can set auto-refresh, formatting preservation, etc. PivotTables/Charts can refer to the data and can made up to update upon data refresh with a few lines of VBA, for example.
This is often a much simpler solution than VSTO if it can meet the requirements.
Another option would be to use a third party Excel file generation assembly.