Mathias Brandewinder on .NET, VSTO and Excel development, and quantitative analysis.
by Mathias 14. April 2009 14:55

Rather than trying to get the mythical perfect compromise - a powerful yet portable laptop – I went for the other option, and complemented my very-powerful-but-absolutely-not-portable laptop (I had to search hard to find a laptop bag where it would fit…) with a Dell Inspiron Mini 9 (2.3 pounds, 232mm width, 32GB solid-state hard drive). Too early to tell how much I like it yet, but the contrast between the two is striking. Next step: putting Windows 7 on.

MiniMe

by Mathias 9. April 2009 14:51

Through the twitter feed of Tim O’Reilly, I came across this great post on network flow algorithms. Not only did I have fun revisiting the Min Cut / Max Flow, but there was a great link to an article listing the “10 algorithms with the greatest influence on the development and practice of science and engineering in the 20th century”. I am very excited, as for a few of them, I have absolutely no idea what they are about; it has always fascinated me to see the isolation of research fields, and how much they don’t know about each other.

Here is the official list:

Metropolis Algorithm for Monte Carlo

Simplex Method for Linear Programming

Krylov Subspace Iteration Methods

The Decompositional Approach to Matrix Computations

The Fortran Optimizing Compiler

QR Algorithm for Computing Eigenvalues

Quicksort Algorithm for Sorting

Fast Fourier Transform

Integer Relation Detection

Fast Multipole Method

Which ones do you know? And how did you come across them?

by Mathias 9. April 2009 10:54

In my previous post, I described how to programmatically add an embedded chart to an Excel worksheet, and what issues I encountered in the process. I was not very happy with the solution, and figured out a much better way to do this, inspired largely by this. Rather than add a chart to the workbook, and then set its location, it is possible to directly add the chart to a worksheet, by using the following syntax:

public static Excel.Chart AddEmbeddedChart(Excel.Worksheet worksheet, 
Excel.XlChartType chartType, Excel.Range dataRange, Excel.XlRowCol byRowOrCol, 
string title, double left, double top, double width, double height)
{
    Excel.ChartObjects chartObjects = (Excel.ChartObjects)(worksheet.ChartObjects(Missing.Value));
    Excel.ChartObject chartObject = chartObjects.Add(left, top, width, height);
    Excel.Chart embeddedChart = chartObject.Chart;
    embeddedChart.ChartType = chartType;
    embeddedChart.SetSourceData(dataRange, byRowOrCol);

    embeddedChart.HasTitle = true;
    embeddedChart.ChartTitle.Text = title;

    return embeddedChart;
}

Instead of creating a chart sheet first, and then re-locating (a copy of) the chart into the target worksheet, this version directly creates the chart in the right place. The cherry on the cake: you can set the location and size of the chart immediately, instead of having to perform acrobatics to retrieve the chart in the sheet...

So why did I go the wrong path first? Because of my best but not always reliable friend, the Macro Recorder.

More...

by Mathias 6. April 2009 10:36

Just like an embedded journalist becomes something else in the process, I discovered with great pain that manipulating an Excel embedded chart through .NET isn't quite the same as working with a plain chart.

To add a chart programmatically, a snippet of code along these lines will do the job, creating a new sheet to host the chart:

public static Excel.Chart AddChart(Excel.Workbook workbook, string chartSheetName, string title, Excel.XlChartType chartType, Excel.Range dataRange, Excel.XlRowCol byRowOrCol)
{
    Excel.Chart = (Excel.Chart)workbook.Charts.Add(Missing.Value, Missing.Value, Missing.Value, Missing.Value);
    chart.ChartType = chartType;
    chart.Location(Excel.XlChartLocation.xlLocationAsNewSheet, chartSheetName);
    chart.SetSourceData(dataRange, byRowOrCol);
    chart.HasTitle = true;
    chart.ChartTitle.Text = title;
    return chart;
}

When my client asked if it would be possible to add all the charts in the same worksheet, I expected that accessing and positioning them would be a challenge; what I didn't anticipate was that simply changing the line "Chart.Location" in the code above would cause problems, too.

More...

by Mathias 5. April 2009 16:53

The Legendary Juval Lowy will conduct a free half-day seminar introducing the EnergyNet. The EnergyNet is a massive new software system analogous to the Internet, transferring watts and usage data instead of packets and request, connecting anything and everything in the energy market. He will demonstrate why software developers should care and how they can become engaged in this exciting new field, and point out the skills and expertise required for those that want to not only survive but thrive on the next boom in software.

This should be a great event. Juval is an amazing speaker, and I haven’t heard him being so fired up about something since a while!

More information here.

Where and when

Microsoft San Francisco
835 Market Street, Suite 700
San Francisco, CA 94103

Tuesday, Apr. 21, 2009
9:00 AM  - 1:00 PM

Comments

Comment RSS