Question

Bottom Line:

What is the simplest set of changes I can make to keep these sheets working as they have before? (The whole system gets retired in another 8 - 10 months, it doesn't have to be the prettiest fix)


Background:

We've got an ... older ... program generating a bunch of Excel XML/HTML spreadsheets. The sheets are plain text XML/HTML with a '.xls' extension. Yes, we get the data format message, and the folks that need to use it can carry on with that message just fine.

It's been running since we had Office 2000 as the company standard (and was originally written against what Excel 2000 supported); and has continued to be used, requiring only minor tweaking to continue functioning through the upgrades to Office 2003 and Office 2007.

Now our IT department1 is starting to roll out Office 2010 as a part of a much more locked down image of Windows 7, and those folks are having problems with the generated sheets. To be clear: Everyone still using Office 2007 is able to use the sheets just fine - it's only Office 2010.

The problem seems to be related to the data validation section.

  • Removing it completely works (though we would end up getting the crap data that caused us to add it in the first place).
  • A minor edit removes the blocking error (the sheet opens), but the validation is not present.
  • Other edits based on what I've found around the net end up causing errors themselves or resulting in the second bullet...

What should happen is each cell should present a drop-down with a list of dates that is populated by another column on the same sheet.


Code:

All the sheets start off with the Office 2000 style:

<html xmlns:x="urn:schemas-microsoft-com:office:excel">
<head>
<style>
<!--table
@page
{mso-header-data:"&CRegistrationList\000APrinted\: &D\000APage &P";}
br
{mso-data-placement:same-cell;}
-->
td {border:1px solid black; border-collapse:collapse;}
td.EvenRow {background:#F5F5F5; color:black;}
td.OddRow {background:#DCDCDC; color:black;}

Cutting a few lines for the sake of brevity...

</style>
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>RegistrationList</x:Name>

Cutting some more to get to the part that is actually causing errors: (with some extra for context, comments not in the original)

</x:WorksheetOptions>
<x:DataValidation>
<x:Range>G:G</x:Range>
<x:Type>List</x:Type>
<x:Value>$K$2:$K$34</x:Value>
<x:InputMessage>Select Date from list</x:InputMessage>
<x:ErrorMessage>You must select a date from the list. Press 'Cancel' to continue.</x:ErrorMessage>
</x:DataValidation>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml><![endif]-->
</head>
<body>
<table>
<tr>
<th style="mso-protection:locked visible; width:95px;">EmployeeNumber</th> <!-- Col. A -->
<th style="mso-protection:locked visible; width:120px;">LastName</th> <!-- Col. B -->
<th style="mso-protection:locked visible; width:120px;">FirstName</th> <!-- Col. C -->
<th style="mso-protection:locked visible; width:80px;">AccountingCode</th> <!-- Col. D -->
<th style="mso-protection:locked visible; width:90px;">ClinicalCreds</th> <!-- Col. E -->
<th style="mso-protection:locked visible; width:0px;">Extension</th> <!-- Col. F -->
<th style="mso-protection:locked visible; width:170px;">DateToRegister</th> <!-- Col. G -->
<th style="mso-protection:locked visible; width:170px;">Notes</th> <!-- Col. H -->
<th style="mso-protection:locked visible; width:170px;">CPRExpDate</th> <!-- Col. I -->
<th style="mso-protection:locked visible; width:200px;">AdminNotice</th> <!-- Col. J -->
<th style="mso-protection:locked; width:0px;">DataValidation</th> <!-- Col. K -->
</tr>

From there we continue with a regular HTML table containing the spreadsheet data.

I found one other question here that looked close, and tried a variety of permutations of the code there with no luck.

<x:dataValidations count="1">
    <x:dataValidation type="list" showInputMessage="1" showErrorMessage="1" sqref="G:G">
        <x:formula1>$K$2:$K$34</x:formula1>
    </x:dataValidation>
</x:dataValidations>

Adding a <x:DataValidations count="1"> wrapper (like below) gets rid of the error message preventing the sheet from opening, but does not enable the data validation in Office 2010 (still trying to get my hands on a VM or something to make sure this doesn't break those with Office 2007).

<x:DataValidations count="1">
<x:DataValidation>
<x:Range>G:G</x:Range>
<x:Type>List</x:Type>
<x:Value>$K$2:$K$34</x:Value>
<x:InputMessage>Select Date from list</x:InputMessage>
<x:ErrorMessage>You must select a date from the list. Press 'Cancel' to continue.</x:ErrorMessage>
</x:DataValidation>
</x:DataValidations>


Summary:

And that brings us back to the original question: What is the simplest set of changes I can make to keep these sheets working as they have before? (The whole system gets retired in another 8 - 10 months, it doesn't have to be the prettiest fix)

There are always other options (copy/paste a template and stuff it with data via Jet ODBC), but that sort of thing takes an awful lot of work for something due to go away in the near future.


1 I have the joy of being a programmer not in our IT department - it has its advantages and disadvantages. I mention only because some of the suggestible options may be outside my scope to fix, but with enough evidence I can probably convince IT to change.

Was it helpful?

Solution

Leaving this up as a placeholder - due to work pressures if there isn't a working option by the time I get to work Tuesday morning, I'll have to write a new program that will:

  1. Copy and re-name "template.xlsx"
    (the file will have all the appropriate data validation, conditional formatting, etc.)
  2. Add the data to the blank file via JET/ADODB
  3. Rinse, Repeat until all the sheets are created

It will push everything else back a day, but I just don't have the time available :(

OTHER TIPS

Try defining the range in R1C1 notation. I am on Excel 2013 and saved a file with data validation as an XML Spreadsheet (2003 version, so it might not have the same syntax). Here's a sample of data validation on cell C3 with the acceptable values defined as E3:E5:

  <DataValidation xmlns="urn:schemas-microsoft-com:office:excel">
   <Range>R3C3</Range>
   <Type>List</Type>
   <Value>R3C5:R5C5</Value>
  </DataValidation>

Like I said, I would stick with the syntax you have been using, but try to replace the A1 cell notation with R1C1.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top