by Mathias
3. August 2009 10:16
I just completed a fun project a few days ago, a C# application which performed lots of reading from and writing to Excel. One small problem got me stumped: I know how to add a standard chart, but I couldn’t figure out how to add charts from the Custom Types selection. Most of these are utterly useless (There is an “Outdoors Bar” type, which is “A bar chart with an outdoor look”. I am not making this up.), except for one: the “Line – Column” chart type, and its variations on 2 axes.
I like Outdoorsy charts
The VBA macro recorder spat out this:
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:="Line - Column"
So I check the Chart object in C# and sure enough it has a method ApplyCustomType(Excel.XlChartType CharType, object TypeName). Problem: the enumeration Excel.XlChartType does not contain anything like XlBuiltIn. Damn.
Long story short: xlBuiltIn is to be found in the enum XlChartGallery, and the type name is passed as a good old magic string. This code does the job:
Edit, August 20, 2009: this code works for Excel 2003, but not for Excel 2007. Check this post for an updated version of the code which follows the suggestion of Jon Peltier, Master of Charts.
// create your chart first
string builtInType = "Line - Column";
Excel.XlChartType customChartType = (XlChartType)XlChartGallery.xlBuiltIn;
chart.ApplyCustomType(customChartType, builtInType);
ab8c4a6c-0b04-482d-8b8c-e114901ed463|0|.0
by Mathias
1. August 2009 15:18
Even though I develop with WPF, I haven’t really used Blend so far: as of now, I am simply more comfortable working directly with xaml in Visual Studio. However, I was intrigued when I recently heard that the upcoming Microsoft Blend 3 version came with Sketchflow, a UI prototyping tool, so I downloaded the trial version and gave it a quick spin.
I spent about one hour playing with it, barely enough to give it justice (especially so when you practice the mantra “user manuals and tutorial are for wimps”), but I really liked what I saw. Sketchflow allows you to
- Rapidly design screens using Blend, adding real WPF control and defining the flow between screens based on user actions on the controls,
- Build the prototype so that another person can run it and experience interacting with the application,
- Collect feedback on the prototype.
I created a simple application, where a user can view a list of products, and add new products. This is how Sketchflow looks: the top part displays your screen, the bottom the flow between the existing screens. To edit your prototype, you simply add and format controls, and define which screen they lead to if need be.
More...
deaf22da-90e8-4514-a9ce-a929bd2cbf67|0|.0