Multiple charts in EPPlus - c#

This question will most probably get downvoted, but I'll ask anyways since I can't find an answer elsewhere. I'm working on a data processing application which processes a large amount of data and writes them to an excel file using EPPlus. I now have to create some graphs with the data in the excel programmatically through EPPlus. Since I'm not really an expert on EPPlus, I'm looking for some online resource or documentation that could help me with charts. I've searched online but I couldn't find a single place, where they list all possible chart types that could be made with EPPLus and how. If anyone knows of some online resource where they all list everything related to charts via EPPlus, it would really help me. Any help is appreciated!

Seems like a perfectly reasonable question. I agree, documentation is fairly light - but hey its free so I am happy with whatever they can give us :).
By far, the most helpful thing I have done with Epplus is downloading the source code and reverse engineering it. When I try to figure out a particular chart type I look at this:
http://epplus.codeplex.com/SourceControl/latest#EPPlus/Drawing/Chart/ExcelChart.cs
Particularly, look at the enum eChartType:
public enum eChartType
{
Area3D=-4098,
AreaStacked3D=78,
AreaStacked1003D=79,
BarClustered3D= 60,
BarStacked3D=61,
BarStacked1003D=62,
Column3D=-4100,
ColumnClustered3D=54,
ColumnStacked3D=55,
ColumnStacked1003D=56,
Line3D=-4101,
Pie3D=-4102,
PieExploded3D=70,
Area=1,
AreaStacked=76,
AreaStacked100=77,
BarClustered=57,
BarOfPie=71,
BarStacked=58,
BarStacked100=59,
Bubble=15,
Bubble3DEffect=87,
ColumnClustered=51,
ColumnStacked=52,
ColumnStacked100=53,
ConeBarClustered=102,
ConeBarStacked=103,
ConeBarStacked100=104,
ConeCol=105,
ConeColClustered=99,
ConeColStacked=100,
ConeColStacked100=101,
CylinderBarClustered=95,
CylinderBarStacked=96,
CylinderBarStacked100=97,
CylinderCol=98,
CylinderColClustered=92,
CylinderColStacked=93,
CylinderColStacked100=94,
Doughnut=-4120,
DoughnutExploded=80,
Line=4,
LineMarkers=65,
LineMarkersStacked=66,
LineMarkersStacked100=67,
LineStacked=63,
LineStacked100=64,
Pie=5,
PieExploded=69,
PieOfPie=68,
PyramidBarClustered=109,
PyramidBarStacked=110,
PyramidBarStacked100=111,
PyramidCol=112,
PyramidColClustered=106,
PyramidColStacked=107,
PyramidColStacked100=108,
Radar=-4151,
RadarFilled=82,
RadarMarkers=81,
StockHLC=88,
StockOHLC=89,
StockVHLC=90,
StockVOHLC=91,
Surface=83,
SurfaceTopView=85,
SurfaceTopViewWireframe=86,
SurfaceWireframe=84,
XYScatter=-4169,
XYScatterLines=74,
XYScatterLinesNoMarkers=75,
XYScatterSmooth=72,
XYScatterSmoothNoMarkers=73
}
As for "how", this the tougher part. But fortunately they all follow a consistent pattern so usually if can figure it out fairly quickly with a little trial and error. Usually starts with something like:
var chart1 = wsContent.Drawings.AddChart("Chart1", eChartType.XYScatterLines);

The documentation is indeed not really complete at that point. I would suggest look at the small list at: http://epplus.codeplex.com/releases/view/118053 ("Chart Types).
Also, the demo buids may help and lastly, their sourcecode is online. Start searching for a known chartttype and take a look at what other values are allowed.

Related

Filter elements in Revit and set parameter

Hello everybody,
around two or three month ago I started to learn Dynamo for Revit... finally :)
After learning and testing a lot, I got a few own scripts working. Then I learned Python, because I couldn't create the next script only with Dynamo-Nodes.
Then I thought "Let's see how difficult it is to get something done as a PlugIn".
I watched some Videos and read a lot of stuff.
Finally I got the Revit-AddIn-Wizard installed and made my first small Test-PlugIn.
Great...
Now I have a few problems which I do not understand... so I thought I will try my luck here... because I got so much information and help, reading through this site.
My goal was/is the following: (I tell you what I have now)
A form with a few buttons, comboboxes and a DataGridView.
I can load an Excelfile, click on "Show" to show it in the DataGridView.
The header of each row will be automatically put into 3 comboboxes.
In the first combobox you select the first search-parameter, in the second you CAN select another search-parameter and in the third combobox you select the parameter you want to set.
I have a checkbox to switch from type- to instance-parameter for the search- and the set-operation.
There is also a button which shows another small form with a list of categories (I won't search for ALL, only nearly all modelcategories).
PlugIn
I took me a lot of "watching Videos, reading through the internet, testing, testing and testing".
Thanks to this site here and a few others... I managed to get this whole PlugIn nearly 100% working.
But now I have a few strange issues and I have absolutely no clue on how to fix them or if it is possible. And I really hope that someone can help me.
First... I just tell you my problems and perhaps someone can say "this really IS an issue!" or that it is possible to get it done. Then I would post some code.
So... what do I do?!
1. I have a FilteredElementCollector which filters ALL elements.
2. Depending on my "Type/Instance-Checkboxes" I do .WhereElementIsElementType OR .WhereElementIsNotElementType.
3. Then it passes a MultiCategoryFilter to get the big list down to only the modelcategories.
4. Next, the collection passes one of ten different "methods" depending on all settings. There I filter this collection depending on the searchlists-comboboxes. When the combobox says "Familie" or "Typ" then it filters for ".BuiltInParameter.SymbolFamilyName" or ".Name" otherwise it just uses ".LookupParameter".
After that I have a collection with only the elements of selected categories which contains the values from the Excellist.
5. Depending on what my search- and set-settings are (e.g. search for type and set instance) I have to get the instances from the collected types or the other way around.
6. Then I pass it down to another method where I finally set the parameter.
So... Excelheader goes into comboboxes, depending on what you select in there it creates lists with the values of the selected rows.
I hope you all understand.
Now... where are my problems?
When I search for type-familynames or instance-parameter and set a typeparameter it works for ALL categories without any error.
1. When I try to set an instanceparameter (doesn't matter what my search-setting are) it works for all "normal" families but not for the systemfamilies (e.g. walls, floors, pipes etc.). No error, just nothing happens WHY? It seems that I cannot set an instance-parameter for system-families.
2. Roofs, Stairs, CurtainPanels and GenericModel make problems when I search for a typeparameter Error is something like "The object reference was not set to an object instance". Only with these 4 categories and it doesn't matter what I want to set... but when I search for family-/typeNAME or Instance-Parameter, then I can set type or instance and it works (except instance for sysfam).
3. When I try to search AND set an instance-parameter it works for ALL categories EXCEPT if one wall does not contain a search value... it really is enough that ONE wall does not have a search-param-value that everything will be cancelled.
I have a few other small problems... but I hope someone can help me with these problems... I would be extremely thankfull
greetings and have a nice day or night :)
Philipp
Tl; dr.
The three problems you describe sound like your own. I have no heard anybody else runAsk three separate questions and provide three separate minimal code snippets describing how they arise,. into those. I suggest that you create three separate independent minimal reproducible cases to demonstrate all three issues. Chances are, when you simplify and minimalise your code, the problem will go away. If it does not, it might just possibly be in a small and manageable enough state for other people to help you take a look at it. Given the long-winded description above, nobody in the world can help you.
Thank you for your answer Jeremy,
as I said, as a first start it is ok for me if you don't say "With theses categories, there are indeed some issues!"
I think I've managed to create 3 small examples of my problems.
For each problem I made a zip-file containing the complete visual-studio folder, a small exampleproject and a readme.txt with (I hope) enough information to understand everything in detail.
Problem1
Problem3
You only need to compile them or copy the .addin and .ddl files into the Revit AddIn folder. Then you get the new ribbons.
Short problem summary = I get problems when searching for parametervalues and setting values to another parameter.
Edit: I just solved the 2. problem when searching for familynames and setting system-families-parameter.
I used:
ElementClassFilter ecf = new ElementClassFilter(typeof(FamilyInstance));
FilteredElementColletor colle2 = new FilteredElementCollector(doc);
colle2.WherePasses(ecf);
I simply deleted the ClassFilter and do it now like in the other cases where I need instances.
FilteredElementCollector colle2 = new FilteredElementCollector(doc);
colle2.WhereElementIsNotElementType();
The 1. and 3. problem still exist :/
I would be thankful for any help someone can provide :)

Excel-DNA: grouping rows via C API feature of Excel-DNA

I'm familiar with how to group a range in Excel VSTO/COM interop:
ws.EnableOutlining = true;
ws.Outline.SummaryRow = XlSummaryRow.xlSummaryAbove;
var rng = GetRangeSomeHow();
rng.EntireRow.Group();
rng.EntireRow.OutlineLevel = someLevel;
What is the most efficient way to do this in Excel-DNA? I would imagine there must be a C-API way to do it, encapsulated cleverly in Excel-DNA somehow, but for the life of me, I can't figure it out via online documentation (incl. Google).
There's a lot of posts using code similar to my sample above, but these are pretty expensive calls, especially since I need to do this ~5000 times overall (I have a really big data set).
EDIT:
So there seems to be this method call:
XlCall.Excel(XlCall.xlfGroup...)
The only problem is, I have no idea what the parameters are. It seems an ExcelReference should be passed in, but how is the .EntireRow resolved? Will the C API just handle it for me - in which case I just need to pass a new ExcelReference(1,100,1,1) and be done with it... or is there more to this?
Thanks in advance to anyone who can answer my question!
I don't think the C API GROUP function is te one you're looking for. The documentation says:
GROUP
Creates a single object from several selected objects and returns the
object identifier of the group (for example, "Group 5"). Use GROUP to
combine a number of objects so that you can move or resize them
together.
If no object is selected, only one object is selected, or a group is
already selected, GROUP returns the #VALUE! error value and interrupts
the macro.
I'd suggest you use the COM object model for this kind of thing, even in an Excel-DNA add-in. The C API has not really been updated over the years for the general sheet manipulation like this case, so you're likely to run into some features that don't work right or are incomplete relative to the COM object model.
From your Excel-DNA add-in, just make sure your get hold of the right Application root object with a call to ExcelDnaUtil.Application.
For improved performance of this kind of sheet editing, you pretty much have to use the same tricks as from VBA or VSTO - disable screen updating and calculations etc.

How to configure tolkenizers with indexing and searching with Lucene and Nhibernate

This is a question for using Lucene via the NHibernate.Search namespace, which works in conjunction with Lucene.
I'm indexing a Title in the Index: Grey's Anatomy
Title : "Grey's Anatomy"
By using Luke, I see that that title is getting Tokenized into:
Title: anatomy
Title: grey
Now, I get a result if I search for:
"grey" or "grey's"
However, if I search for "greys" then I get nothing.
I would like "greys" to return a result. And I guess this could be an issue with any word with an apostrophe.
So, here are some questions:
Am I right in thinking I could fix this issue either by changing something on the time of index (so, changing the tolkenizer..??) or changing it a query time (query parser?)
If there is a solution, could someone provide a small code sample?
thanks
If you make a classic Term search using Lucene, then greys it's most likely not to show on the results, except that you make a nice tokenizing work when saving, so from where I see it, you have 2 choices or a 3rd beign a combination of them:
Use a Stemmer for indexed data and query. Stemmers are fast, and you can always find an implementation of Porter's stemmer somewhere in Google. Problem is when you look for different languages.
Use Fuzzy queries. Using a Fuzzy Query you can set the edit distance that you want to get "away" from the word being search. The thing is that because 2 words are "close" using an edition distance (i.e, Lehvenstein) doesn't mean that they're the same, but the problem of Grey and Grey's and Greys should be solved with setting an edit distance of 2.
I think you will be able to find a decent implementation of the Porter Stemmer, which is nice right here.
Hope I can help!

Pretty printing of DateTime values in C#

I'm hoping that someone has found a way of doing this already or that there is a library already in existence. It's one of those things that would be nice but is in no way necessary for the time being.
The functionality I'm looking for is something like datejs in reverse.
Thanks,
Simon.
Thanks, using something like the dddd example might be a good start towards usability. The more I think about this problem the more it depends on the values being used. I'm specifically dealing with a series of timestamped versions of a document so there is a good chance that they will be clustered. Today isn't so hot if you have saved it three times in the last five minutes.
If I come up with something I'll share it with the community.
Actually, what you really want is the Custom DateTime Format strings:
http://msdn.microsoft.com/en-us/library/8kb3ddd4(VS.71).aspx
DateTime.Now.ToString("ggyyyy$dd-MMM (dddd)")
will return "A.D.2008$06-Nov (Thursday)" if that's what you want.
And to get something closr to datejs ("in forward"), you can use the same strings in DateTime.ParseExact()
http://msdn.microsoft.com/en-us/library/az4se3k1(VS.71).aspx should get you on your way,

Adding words to SQL Server Full Text Stemmer

I've dug around for a few hours now and cannot find an option to do this. What I would like to do is to add words to the stemmer used by Full Text in SQL Server. I work for an agency that would like to search on variations of names. In other words, if an officer enters the name of "Bill" I would also get a hit on "Will" or "William". Anyone know if this is possible?
I did look at implementing a custom IStemmable interface but that seems a bit of an overblow solution to this problem. Does anyone know of an easier way or have an off the shelf solution that will do this?
Thanks...
In SQL Server 2K5 or 2K8 it is called the "Thesaurus". Well doced in MSDN etc
It handles things like these
<expansion>
<sub>Internet Explorer</sub>
<sub>IE</sub>
<sub>IE5</sub>
</expansion>
<replacement>
<pat>NT5</pat>
<pat>W2K</pat>
<sub>Windows 2000</sub>
</replacement>
<expansion>
<sub>run</sub>
<sub>jog</sub>
</expansion>
Sigh....
Thanks. One of those times I was definitely trying to make it more difficult then it needed to be. I think I found stemmer early on and kept using it in my searches.
Thanks again.

Categories