Blog
All Blog Posts | Next Post | Previous PostFlexCel.NET, IPhone, MonoTouch and some magic dust
Monday, November 1, 2010
For some time now I have been wanting to evaluate how FlexCel .NET behaves in other platforms. Not just plain Mono running in a Linux server (that's boring, we have always supported that), but some more fun possibilities.
That's why I decided to try two different technologies this weekend: MonoTouch and CrossTalk. (I will speak about Cross Talk in a separate post).
As you might know, we have been really busy here at FlexCel development, both in VCL (porting all features from FlexCel .NET back to FlexCel VCL) and in .NET (adding the missing xlsx support bits). So I had not too much time to play before going back to "real" coding. I allocated 5 hours in the weekend to test each one; if I couldn't have something working when time was due, I would give up.
And if I have to be sincere I was completely expecting to give up. Even when most of FlexCel code is non visual, it is over 100,000 lines of complex non visual code, and I didn't imagine I was going to have something compiling, let's not say working, in 5 hours. You are a smart reader, and you know I actually got something to show or I wouldn't be writing this post, but I didn't know that while I was waiting for MonoTouch to download. That's why I want to emphasize how impressed I was.
So I installed MonoTouch, launched MonoDevelop, and added all the files from the "Core" FlexCel namespace to a new project. I pressed the little "compile all" button; the project compiled and reported "0 errors". What? 0 Errors?? Something had to be wrong, and indeed it was. No file had been generated. Tried to compile a couple of times, and always the same result. Finally when trying to change some options to make it compile, MonoDevelop crashed and dissapeared.
Not what I would call a good start, and it set my expectations even lower. I wasn't going to be able to do anything nice in my 4.5 hours left. But well, I still had time, so I tried it again from zero; created a new project, added just one file and compiled it. And finally I got some errors! Encouraged by that small victory, I tried again to put the full "Core" namespace in the project, and this time it compiled and gave a gazillon of errors. Looking at them, most were about some missing classes, repeated once and again. No "System.Drawing.Font". No "System.Drawing.Image" And again. And again. But I did find some similar classes "MonoTouch.UIKit.UIFont" and "MonoTouch.UIKit.UIImage", that looked like good replacements.
Next step was then to start writing at the beginning of each file:
#if(MONOTOUCH) using Font = MonoTouch.UIKit.Font; using Image = MonoTouch.UIKit.Image; #endif
type Font = MonoTouch.UIKit.Font;
Bit well, after that things started to look good. Now my issue was with different methods, for example "System.Drawing.Font" has a "FromArgb(a,r,g,b)" method, while "MonoTouch.UIKit.Font" has a "FromRGBA(r,g,b,a)". To fix that I created some extension methods that extended the MonoTouch classes to have similar interface to what FlexCel expected. I had no such luck with properties, since C# doesn't allow extension properties. So I had to change things like Color.R to Color.R() in code, and create an extension method "R()" that will return the property "R" in normal framework and the equivalent in MonoTouch.
Finally after one hour, the "Core" namespace was compiling. At this time I had forgotten about my first bad impression, and was very excited to see everything compiling. I didn't really believe it would actually work, but just seeing it compiling was great. After that it took me other 30 minutes to compile "XlsAdapter" namespace (the actual xls engine). I had to remove xlsx support because some missing classes in the framework, and I didn't even try to compile the rendering engine (as it has more visual stuff, and I expect it to be a little harder)
Now two hours had gone, and I already had something that compiled and looked like I could actually use. So now I went to make a small test application. I have zero experience in mac development, but I could get a form with some labels and buttons relatively fast. And now comes what really impressed me. Everything worked! At first try! I had a working calculator in 3 hours.
I was so happy that I created a little screencast to show how it to some friends. My idea was to create a more "professional" one for this post, (where I would even try to correctly pronounce "button"), but I feel the original one is more authentic and probably funnier to watch. Of course the screencast has no script, I just pressed "record" and started babbling things in an impossible to understand pseudo English. Not that I am any better doing a speech in Spanish, but that's off topic.
You can get the screencast here:
https://download.tmssoftware.com/download/flexmonotouch.mov
After I recorded that I tested some other things, and everything went incredible smooth. For example creating a 60,000 rows x 20 cols (8.5mb) spreadsheet from the iPhone simulator just took seconds, in fact Excel was slower opening the file than the iPhone simulator creating it. Wow. Mono has always been outstanding technology, but what they did with MonoTouch is just incredible.
So there you have it. From void to a fully working app in 3 hours. Just so we can compare, I am still trying to port FlexCel to Windows phone 7. So much stuff missing and changed in wp7 that I would need many other blog posts to enumerate them all. And in the meantime, MonoTouch just worked, in a platform that is designed around compiled obj-c, not .NET, not even a JITter allowed. Some serious magic is going on here.
Now, I am not really sure on what we are going to do with this. Is it really interesting to have support for reading and writing Excel files from a phone? Would you use it? Do we leave this as a "cool experiment" or do we keep working on it? Please let us know in the comments, or email me directly at adrian@tmssoftware.com
Adrian Gallero
This blog post has received 5 comments.
Sadly, I am not really sure when we will be finishing porting it, but I can tell you I am spending about 8 hours every day on it, and I have for some time. I think it is not too far away, but as said, I can''t commit to a date, as we won''t release it until I feel that it is ready. (last think I want is to release a buggy product because I was in a hurry for some imaginary deadline) Anyway, I hope I will have more concrete news soon.
About the plans, no, we don''t have plans to add it to other packs at the moment. The products you see in VCL sub but not in other TMS packs (like FlexCel or Diagram studio) have different development teams and product managers (myself in the FlexCel case), than the "main" TMS products. So the logistics of including FlexCel in a "pack" are more complex than with other products.
But more important than that, FlexCel is not as mainstream as a grid or a glow button can be; everybody needs a grid, but not everybody needs to import or export from/to Excel. So, when you buy it, you are telling us "I needed that functionality" and that is important for us to know. If you are buying some giant pack, we really don''t know if you (or anybody) cares or not about the included FlexCel functionality.
FlexCel is also quite cheap right now if you are a tms customer (euro 60 if you use the "my offers" link in the registration page), so for people who needs it it isn''t a hugely expensive thing to buy. Prices are actually most likely to go up when we release v5 as the array of new features is huge, as it is the effort and man hours we had to put into the project.
Adrian Gallero
Real performance on device can be lower!
Deksden
Glad to see that it''s possible to port to MonoTouch.
I''ve tried to port it to Silverlight, but stuck with all this legacy WinForms code.
Do you have some plans to release Silverlight/WinRT version anytime soon?
Lex Lavnikov
There isn''t actually any winforms code in FlexCel.dll (all winforms code is in FlexCelWinforms.dll, and FlexCelWinforms.dll is very small). But what we used to have is a lot of System.Drawing references (for example to System.Drawing.Color) which won''t work in SilverLigut/WinRT.
Sadly Microsoft has been rewriting and rewriting and rewriting their graphics stack from scratch every other year, so we have things like winforms/wpf/silverlight/winrt. On the mono side, monotouch and monodroid also use different graphics stacks.
So we have already internally removed any reference to system.drawing, and now use platform independent classes like UIColor, which will map to a System.Drawing.Color when using System.Drawing, or to whatever it is if you are using a different graphics stack. This is already done here and working, but it is half of the work, there are many other things missing/changed in both silverlight and winrt.
Next version of FlexCel.NET will have winrt support and native wpf graphics too, we are working on that right now and things look good. But I am not so sure about silverlight, silverlight is already "dead" and I am afraid adding a lot of code to support a technology that won''t move forward won''t make much sense. Today, you could use SL still for windows phone 7, but windows phone 8 won''t use it anymore.
Regards,
Adrian Gallero
All Blog Posts | Next Post | Previous Post
Do you plan to add FlexCel VCL to a subscription other than $695 TMS VCL Subscription (e.g., TMS Component Pack)?
Charles