Maarten Balliauw {blog}

ASP.NET, ASP.NET MVC, Windows Azure, PHP, ...

NAVIGATION - SEARCH

Excel Formula Parsing using PHP?

One of the new (planned) features of PHPExcel is to implement parsing and calculating Excel formulas. One thing every developer should do is not to try to reinvent the wheel. Therefore, a Google search learned me someone wrote a Excel expression parser in JavaScript, which parses an expression into a tree.

Parsing Excel formulas (expressions) in JavaScript is done here. Someone ported this to C# too, and as of today, it is ported to PHP5 too 8-).

The only thing left to do is building this into PHPExcel, and performing calculations using the parsed tree...

MCTS for .NET framework 2.0 Web applications

Just like my colleague Kristof did last friday, I passed the Microsoft.NET Framework 2.0 - Web-based Client Development (Exam 070-528) exam yesterday, resulting in a new certification title: I'm now offically a Microsoft Certified Technology Specialist for .NET framework 2.0 Web applications.

SendMailControl for ASP.NET

Have you ever used the ASP.NET PasswordRecovery control, or the CreateUserWizard? Probably, you used the mail capabilities of these controls too, and set up a MailDefinition to send an e-mail when the control did his job. Personally, I missed this functionality when wanting to send mails to users.

Luckily, ASP.NET is very extensible. I decided to create my own control providing an easy and convenient way to sending templated e-mails. Just set the From, CC, Subject and Body properties in the designer, and use the Send() method from code. Not the cleanest implementation of catching SMTP errors, but it was sufficient for my use. If you need to catch SMTP errors, you still need to add that... Anyway, as a gift for anyone who needs it, please find my SendMailControl underneath:

[code:c#]

using System;
using System.Collections;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;

namespace MaartenBalliauw.WebControls
{
/// <summary>
/// SendMailControl
/// </summary>
[ToolboxData("<{0}:SendMailControl runat=server></{0}:SendMailControl>")]
public class SendMailControl : System.Web.UI.Control
{

#region Private members

private MailDefinition _mailDefinition;

#endregion

#region Constructor

public SendMailControl()
: base()
{
}

#endregion

#region Public properties

[NotifyParentProperty(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Category("Behavior")]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Themeable(false)]
[Localizable(true)]
public MailDefinition MailDefinition
{
get
{
if (this._mailDefinition == null)
{
this._mailDefinition = new MailDefinition();
if (base.IsTrackingViewState)
{
((IStateManager)this._mailDefinition).TrackViewState();
}
}
return this._mailDefinition;
}
}

#endregion

#region Public methods

public void Send(string recipient, IDictionary replacements)
{
try
{
MailMessage mail = MailDefinition.CreateMailMessage(recipient, replacements, this);
SmtpClient c = new SmtpClient();
c.Send(mail);
} catch (Exception) {}
}

#endregion

}
}

[/code]