9

This answer is strangely vacant from the internet, or my google-fu is getting rusty.

I'm making an excel file from C# via xml... When it loads up the worksheet width is pitifully small. Using <ss:WindowWidth>13395</ss:WindowWidth> as prescribed by the internet does... nothing. (edit: tried this in excelworkbook and worksheetoptions, if that gives any idea to the problem) Tried with and without the ss: additions. Also, I cannot seem to find exactly why everyone uses values with this in and around the tens of thousands.

I'm thoroughly confused. If someone links a LMGTFY that answers this I'll eat my hat, because I damn well don't see it.

Silly excel. No one likes you.

Just for you L. Figured windowWidth would give the jist of it.

enter image description here

4
  • "the worksheet width is pitifully small" - meaning the width of the window on the screen? or the number of columns in the worksheet? or ...? Maybe a screenshot would help...
    – LarsH
    Jul 25, 2011 at 21:52
  • What version(s) of office you are targeting? Jul 28, 2011 at 14:21
  • @Remm, are you going to award the Bounty? Aug 3, 2011 at 11:36
  • oh, apparently you're supposed to double click the bounty button. I only clicked it once.
    – Remm
    Aug 4, 2011 at 18:14

2 Answers 2

5
+50

I've seen some people add an ExcelWorkbook element to the 'Workbook' element. The ExcelWorkbook element has WindowWidth and WindowHeight elements.

Here is an example that lists (all?) of the child elements for the ExcelWorkbook element.

<Workbook>
   <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
      <WindowHeight>6795</WindowHeight>
      <WindowWidth>8460</WindowWidth>
      <WindowTopX>120</WindowTopX>
      <WindowTopY>15</WindowTopY>
      <ProtectStructure>False</ProtectStructure>
      <ProtectWindows>False</ProtectWindows>
   </ExcelWorkbook>
   ...
</Workbook>

EDIT

The WindowWidth element is an unsigned int that is specified in twips. Twips is defined as a twentieth of a point.

Twips Link http://en.wikipedia.org/wiki/Twip

2
  • I already have this... A part of the question, though, pertains to the windowheight/width values. What units are they in? '6795' as a programmer doesn't mean jack.
    – Remm
    Jul 28, 2011 at 14:52
  • I interpreted "Using <ss:WindowWidth>13395</ss:WindowWidth> as prescribed by the internet does... nothing" that to mean, it does not control the width, help. The what units are these seemed secondary to the fact that the width was not being controlled. Jul 28, 2011 at 16:10
0

You can maximize the workbook programmatically via the COM interface. In VBA you would do something like this:

ActiveWindow.WindowState = xlMaximized

Maybe that helps.

1
  • I am sending an XML file to the client (C# asp.net). It needs to be done in the xml that I'm sending, which windowWidth should do... but doesn't.
    – Remm
    Jul 28, 2011 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.