Category Archives: Programming

What’s new in OfficeWriter 8.4

PIVOT TABLES ARE HERE!

OfficeWriter 8.4 packs a powerful punch with exciting new features, most notable of which is ExcelApplication support for PivotTables in OOXML (XLSX, XLSM) files. ExcelWriter already supports the use of PivotTables in ExcelTemplate and SSRS reports,  but now you can programmatically create, manipulate, and remove PivotTables with ExcelApplication.

BlogPostPivot

The new PivotTable API gives you the freedom to:

  • Create PivotTables from scratch (see our tutorial on Creating a Basic PivotTable)
  • Add and manipulate PivotTable fields – data value fields, column labels, row labels, and report filter page fields
  • Access common settings like empty/error values, refresh data when opening a file, and the number of cached items to retain

With the API you also have the ability to change the data source of a PivotTable. Continue reading What’s new in OfficeWriter 8.4

Events: Spring 2013 Career Fairs

IMG_1115 Photo 2IMG_1056

Coming to a college near you. We’re Looking for swashbuckling, creative college grads with object-oriented programming under the belts, a penchant for amassing new skills, and who don’t mind a few board games and BBQs. Think you’ve got the coding chops to work in this dynamic office environment? Then we want to meet you.

We’re big on hands-on learning and career development. In years past we’ve had interns work on product demos, pick up a new programming language, and share their expertise on our blog. Have a question? Ask it. Have an opinion? State it. Have an idea? Run with it.

Got you curious? Let our Technical Services team give you an inside look at this eclectic group and the types of projects you could be working on in this video.

Who we are: SoftArtisans is a leading developer of Microsoft Office reporting software. As a key Microsoft partner, SoftArtisans delivers award-winning products to over 20,000 clients in over 70 countries. We’re a company founded on brains not gimmicks and we aim to keep it that way.

Find out more about internship and career opportunities at SoftArtisans and how to join the SA Crew (and get in on those BBQs) by interacting with us on all of the usual social media hotspots or visiting one of the career fairs below. Looking forward to seeing you then!

Spring Career Fairs

Olin College

Wednesday, February 13, 2013, 11 a.m. – 2 p.m. Continue reading Events: Spring 2013 Career Fairs

Best Practices for Performance Testing

Credit: tucowsinc.com

This week I set out to add performance testing to a project I’ve been working on. Why performance test? The main benefit is that we can hone in on when one of the changes we’ve made to a project has affected performance dramatically (such as memory usage, run-time, etc.). It gives us the ability to review performance historically and subsequently identify areas of improvement.

The catch with performance testing is that run-time can vary between runs, making it tricky to test. There are a couple ways to tackle this problem:

  1. The first of which is to run each performance test multiple times and average the results; then compare it to the previous run. This is the most accurate way to go about it, but not necessarily the most cost effective way to spend your time. For instance, if your performance tests take 30 minutes to complete and you need 10 runs to get a good average, that’s a 5 hour test.
  2. Alternatively, we can compare the results of a single test to previous runs and simply identify whether or not the test falls within a desired percent of our distribution. This doesn’t have quite the accuracy of the first approach, but if you don’t expect extreme performance changes it can be a viable option. The biggest downside to this approach is that you won’t necessarily detect deviations immediately.

Right now we don’t have the time to run each test multiple times, so we will be implementing our tests using the second method. For testing the run-time I created a simple function that takes a lambda expression as an argument, so usage would be something like this:

1 TimeExecution( () =>
2 {
3     DoWhatever();
4 };

The implementation ends up looking like this:

01 TimeExecution(Action action)
02 {
03     Stopwatch perfTimer = new Stopwatch();
04
05     perfTimer.Start();
06
07     action();
08
09     perfTimer.Stop();
10
11     _runtime = perfTimer.ElapsedMilliseconds;
12
13     // Store the time and assert failure
14 }

Continue reading Best Practices for Performance Testing

Enhancing your Word Document with Images Using OfficeWriter

One of the questions that comes up frequently when talking with customers is how can they get their images into their Word document with OfficeWriter? Depending on how you are using OfficeWriter and making your Word documents, there are a few ways to do this. The following outline several of these methods and cases in which to use them.

1. Design your document in Word with images

This is the easiest way to get images into your document. Since OfficeWriter can use the Word file you have already created and allow you to enhance it with data from a database, you can get all of the design functionality of Word with the enhanced capabilities of OfficeWriter. This method is commonly used when designing a document that uses your company logo, for example.

2. Dynamically insert images into a document

Another option is to design your document in Word, but leave a place holder for a dynamically loaded image. (A quick overview on how to do this can be found here.) This method is great when the document is structured the same each time it is run and you want to keep your company logo static, but use different department logos.

3. Design your report with images stored in a database

You can use one of two methods to directly insert images into a Word template from an image column: the placeholder method or the the image modifier method.  For example, in MS SQL Server, there is a column type “varbinary” used just for that purpose. This method is perfect for creating an employee directory containing the employee’s picture along with their contact information, or for a product catalog, showing the product alongside the product details. (For further details on how to to design your report with images stored in a database, please see our documentation on inserting an image.)

4. Design your report with images referenced by PATH in a database

This is the more complicated case of the bunch. Unlike the previous instances where you were obtaining your images directly from a database, this process involves accessing your images stored in another location, such as a network share. Continue reading Enhancing your Word Document with Images Using OfficeWriter

Cookie Wars Participant: Alison

On the heels of the successful pumpkin pie extravaganza, 12 brave volunteers will present their finest at a banquet in one week. Before the banquet, we’re holding the Cookie War Challenge: where all of the participants will use technology (bonus points and automatic win if they incorporate the technologies used to power OfficeWriter) to represent their cookie, recipe, or baking process. For example, code your recipe in Chef.

As the cookie contest organizer, I decided to kick it off and use Excel VBA and conditional formatting to represent my entry (Peanut Butter Cookies).

How I did it: I made a macro that updates the timer; then layered conditional formats Continue reading Cookie Wars Participant: Alison

Cookie Wars: What do OfficeWriter, Baked Goods, & Technology Have in Common?

In case you haven’t noticed just yet, along with playing around in .NET and working with Microsoft Office reports, we enjoy food here. This year we’re incorporating both of these passions into a new company-wide challenge to ring in the new year. And this time it involves cookies! Both the kind on your computer and the edible ones that are ever so plentiful this time of year.

The Challenge: Break out and dust off your to-die-for cookie recipes with those secret ingredients handed down from Meemaw to her kids to you, the kind you pull out at parties to impress your friends, the kind people will be talking about at company holiday parties for years to come. Represent your cookie, secret recipe, or baking process using technology (bonus points and automatic win for incorporating technologies that power OfficeWriter.) Example: Create a report in Excel outlining your recipe, code your recipe in Chef (see what we did there), tweet out a line of your recipe every hour on the hour, etc. You can play along at home as well. Post a link to your project in the comments section below and perhaps there will be a little swag in it for you.

The gauntlet has been thrown. Who will win?

Participants:

Dan: CEO. Pub trivia master.

Alison: Product Owner. Pivot Table extraordinaire.

Kate: Technical Services. SharePoint guru.

Nick: IT. Breaks things. Fixes things. And repeat. Continue reading Cookie Wars: What do OfficeWriter, Baked Goods, & Technology Have in Common?

OfficeWriter and the Microsoft Application Platform

Curious to know more about how OfficeWriter fits in with the Microsoft Application Platform? We’ve partnered with Andrew Brust from Blue Badge Insights to bring you an overview of the additive value OfficeWriter provides to the Microsoft stack.

In this powerpoint:

  • You’ll learn about OfficeWriter’s object and template models
  • Scenerios in which to use OfficeWriter
  • How OfficeWriter plays into Microsoft Dynamics, SharePoint, and Azure









Automate Your Holiday Cards with OfficeWriter

With the holidays just around the corner, schedules are becoming increasingly packed. Maybe you’re on the hunt for the perfect gift, or entertaining the slightly overbearing but well-meaning in-laws, or maybe, just maybe, you need to make those last minute travel plans. With all the hustle and bustle, it’s easy to overlook those seemingly insignificant but entirely necessary holiday cards.

As a developer I’m always looking to save time and automate just about everything…even my holiday cards. (Don’t tell my mother she still thinks I spend hours every year making them.) So in the spirit of the giving season, I wanted to share my sample code with you, to get you on your way to automating your holiday cards and back to searching for the perfect stocking stuffers.

Step 1 – Download OfficeWriter:

To get started, you will need to have OfficeWriter installed in order to be able to use the sample code below. In my solution, I used OfficeWriter and its built-in WordTemplate functionality to do a server-side mail merge. If you do not have OfficeWriter, you can download a free evaluation here.

Step 2 – Download Sample Code:

Next, you will need the sample code. Download the sample solution here. This solution comes bundled with:

  • Sample code
  • Easily modifiable templates for both holiday cards and mailing labels
  • Dummy data

Open the solution and run the generator to see sample holiday cards and mailing labels like:

Holiday Card Generator

Sample Output:

Sample Code:

Looking at the sample code you will see that with just about 10 lines of OfficeWriter code I can generate both holiday cards and mailing labels. Continue reading Automate Your Holiday Cards with OfficeWriter

All Kinds of Things You Can Do With SPUser Objects

The SPUser object is a really useful tool, but sadly not very intuitive. Here are some of my favorite SPUser snippets.

People picker list columns don’t return a user object, which is frustrating, but not foreign to those of us with picker experience. An ID is generally returned by a lookup field. Not so for people pickers, which return a domain\user string that is frequently pre-pended by nonsense.

This is how you get a user directly from the list item:

protected SPUser GetUserfromItem(SPListItem userItem)

{

SPFieldUser userField = (SPFieldUser)userItem.Fields.GetField(“User”);

SPFieldUserValue fieldValue = (SPFieldUserValue)userField.GetFieldValue(userItem[userField.Id].ToString());

return fieldValue.User;

}

Now let’s look at a neat little method that grabs some properties by current user! As a side note, there are a lot of issues that are purportedly resolved by setting the context to null – I have never found this helpful. Never. In my lifetime.

//User Properties by user

private bool GetProperty(string userName)

{

//Your return value is a bool

bool found = false;

//Create a profile manager

UserProfileManager profMan;

//Get your site in a “using” so there’s no disposing

using (SPSite site = new SPSite(SPContext.Current.Site.ID))

{

//Make everything unsafe. Just kidding. This is so that you have permissions to edit the profile property.

//If you don’t plan on making changes, you can access the property without this.

Web.AllowUnsafeUpdates = true;

//Okay. Get your web on!

using (SPWeb newWeb = site.OpenWeb())

{

//Get the context and set the profile manager

SPServiceContext context = SPServiceContext.GetContext(site);

profMan = new UserProfileManager(context);

//Get your user profile object

UserProfile prof = profMan.GetUserProfile(userName);

//This is important. Remember to check the Property.Value. Otherwise you are checking to see

//if the property itself is null. And since you know it exists – guess what? It isn’t null. Continue reading All Kinds of Things You Can Do With SPUser Objects

Agile Development: 5 Lessons Learned

Working in software development can be challenging and tricky without the right plan in place, especially without a plan that caters to your employees’ work styles. Here at SoftArtisans our development team follows the agile dogma and we’ve discovered several lessons along the way. Wondering if agile development is right for your team? See below for 5 things to keep in mind when implementing this work style.

1. You absolutely need backup from higher-ups.

Too often I have seen or heard of departments that were “going agile,” but management was not behind them. No matter how enthusiastic about it the developers were, their plans were ruined every time management expected something to be “like it used to.” Managers who don’t give things time to adjust create developers who don’t give things time to adjust, and then everything is doomed to fail.

2. Retros are vital.

One important thing about agile is that you can change things quickly when you need to. This applies to the direction the software is taking, but it also applies to the processes and mindsets of team members. This is what retrospectives are for. A good team will be able to be honest about what’s working and what isn’t and subsequently make changes for future sprints.
This whole process is much easier when…

3. Retros don’t include higher-ups.

Management usually wants to know what’s going on, and that’s great, but retros are not the place for it. Continue reading Agile Development: 5 Lessons Learned