This site uses cookies. By continuing you accept the use of cookies.I Accept

xcode

In December 2010 I took the step over to the Apple side (some call it the dark side) at home. Why? The iMac 27” screen is one of the best screens in the world, but also because of my curiosity. I have been a Windows-user since Windows 3, so I thought it was time to try something different.

A few years back my fiancée bought a Macbook, and since then our home is equipped with iPhones and an iPad. So the last thing to do was to throw out the PC in exchange for an iMac. Don’t get me wrong, I love the PC and Windows, and it’s what I use at work.

This of course opens up a new world, because now it’s possible for me to develop iOS apps. So in December I downloaded Xcode and started programming. Now I find out how good Microsoft.Net really is. Developing in Xcode is everything but simple. The language Objective-C is one of the strangest programming languages I’ve ever came across. Another strange thing is that UI design and programming is separated in two different applications, not integrated as Visual Studio. In the upcoming version (Xcode 4) UI Design and programming is integrated though.

During the Christmas holidays I tested iOS development a lot, and a couple of weeks ago our company Mindbite registered as an iOS development organization, so you can expect a Mindbite App in the App Store in the near future.

This was a short post about iOS development at Mindbite, but it will be followed up regularly.

Last week I started developing a solution for a customer, with the target of creating an Excel Workbook programmatically.

Since we use Microsoft .Net Framework for all our solutions everything is familiar and it’s easy to get started with development against Office applications.

The solution gathers a huge amount of data and fills around 20-30 Worksheets with tables and charts. Everything is based on several filters sent to our application. So the data, number of Worksheets and the design of the charts are designed based on this.

I came across several obstacles in this solution that I want to share.

Debugging

It’s hard to debug an application that is communicating with the Excel Interop. The application simply crashes and the Excel Instance is not killed automatically. So I used one of my screens for the Task Manager, which made it easy for me to kill the instances every time my app crashed.

I still haven’t figured out how to debug this yet.

Performance

When working with the cells in your Worksheet, you must define a Range to work with. The range consists of cells and you can read and write data to them. It didn’t take long before I noticed that every time you put a value in a cell, a call is made to the Excel Interop. Even when putting small amounts of data in a small amount of cells you get slow performance.

The solution is working with Multi Dimensional Arrays, and putting the data into the array. When all data is in its place, you simply write the array to a designated Range in the Worksheet.

image

The example above is an array that works as a matrix. Since I  want to put numbers, strings, dates and formulas in the cells I use object in the array.

After declaring my array I put the data into it:

image

When it’s time to put the data into the Worksheet I do as follow:

image

This performance workaround may seem a little odd, and it’s nothing you’re used to when working with .net. In this case it’s completely necessary.

Using hidden data sources for Charts

In our case we must create several charts based on data that we don’t want to visualize for the person who opens the Excel Workbook. Our solution holds around 150 charts spread over around 25 Worksheets, and the data source for each Chart is unique.

Since (by what I know) you must use cell data as a data source for any chart in Excel we had to create around 150 “tables” containing the data. We felt it would be ugly to display this data in a Worksheet, displayable for any reader.

The solution we used was to create a Worksheet and filling it with data. Then we created the chart and used the data as a Data Source. The last thing we did was to hide the Worksheet that held the data.

You can hide a Worksheet in two ways:

image

This hides the Worksheet, but the user is able to make it visible in the Workbook. So we used the following instead:

image

This completely hides the Worksheet, and the user is unable to make it visible (maybe there is some way but I haven’t found it yet).

Compatibility

This isn’t really an obstacle, other than that a user may use an old version of Office Excel. But when calling the Excel Interop to Save the document to disk, you can provide the version of Excel you want to save for.

image

In our solution, that will be used by any Internet user, we target an older version of Microsoft Excel.

Closing comments

It’s both fun and interesting to work with Visual Studio Tools for Office, and it gives us a great chance to develop better business applications.

The solution we are working on now isn’t made public yet, but I will follow up with more blog posts about this later on.
I will dedicate at least one future blog post to code examples and tips.

As we say in Sweden; Swim Calm!

This is my first blog post in my brand new blog!

My name is Robin Månsson and I'm Head of Development at the company Mindbite AB. Me and my friend Marcus started the company way back in the spring of year 2000. We currently have two employees with great skills in both design and programming.

My primary focus is programming web applications in Microsoft .Net. I started building web sites in the middle of the 90's, and I began programming somewhere around 1998. My first IDE was Visual Studio 3.0 and I haven't left Visual Studio since.

Not only am I a full time programmer, I'm also a full time family man and father. In november 2009 we gave birth to our wonderful daughter Nelly.

By the way, I live in Hultsfred, Sweden. A town most famous for starting one of the first rock festivals in Sweden, but also for having the first northern desert; "Kira's Desert".

Why do I want to blog?

I want to make my way into the community, sharing my experiences and knowledge. But most importantly I want to gain more knowledge by other professional’s feedback on my future posts.

The reason this blog is entirely in English, is because I want a bigger audience for my posts.