Dissecting a file

In this section, I describe the various parts within a typical Excel XLSM (macro-enabled) workbook file. The workbook, named ® sample. xlsm, is shown in Figure 4-4. It has one worksheet, one chart sheet, and a simple VBA macro. The worksheet contains a table, a button (from the Forms controls), a SmartArt diagram, and a photo of a flower.



am» Q]













Figure 4-4: A simple workbook.

CD The sample. xlsm workbook is available on the companion CD-ROM.

To view the innards of an Excel 2007 file, you need to open an Explorer window and add a ZIP extension to the filename. So the ® sample. xlsm file is renamed to sample. xlsm. zip. You can then open the file by using any unzipping program. I use the zip feature built into Windows XP.

Tip You may prefer to extract the zipped files into an uncompressed directory. Doing so makes it easier to view the files. In Windows, right-click the filename and choose Extract All.

The first thing that you notice is that the file contains a directory structure. The left panel of Figure 4-5 shows the fully expanded directory structure for the workbook file. The actual directories will vary with the workbook.

> -Mffipiñ.HiSfl)


F ik- Edil VWrm lira


1 uuh M-r'i-i


QtHK - J >


Mar* £

F ukk'ii

!wn -



(J Uqif.TBI


r*r F ijn

Ïflî/B» 3 35 SH

ù ¿








a n« *

¿a j*

ü lwi*i

* IP lir Ifi

J¡ J«

U -wto


Ü t***

m O -crt*»«




! i J+l'Li [£ik e-ïriaàir: ??.? ÈB


Figure 4-5: The directory structure of the workbook file.

Figure 4-5: The directory structure of the workbook file.

With a few exceptions, all of the files are text files. More specifically, they are XML files. You can view them in a text file editor, an XML editor, a Web browser, or even in Excel. Figure 4-6 shows one of these files viewed in the Firefox browser. The non-XML files include graphic images and VBA projects (these are stored in binary format).

¿f Mejilla Ffatlra

t** Et* Ï^H H**» 1MAM4* yri»

■ ■ r* - » r» »-et«

4 ~1 | M* i ■ "WÎ, «n vtMrljnnl y



- < r:dukH| r<

^ilwffuffiw- hntf1*

'■djHi»ÍM nf 'F;W J

-kfcn+ll, mm sfcPttnrfLhfel^F « m i-fe bid f. i** ld"V ■



dvIiiiftKbHltMebi ¡' :P

taA®«1']' BU* T »n! J] L" «IKiift'Jli'"^

«d toi» ■ - "1J' PBIIIB«lÉ*#-['>

^^'vpH^iufr']: ¡JH:Í nitai>niiih :' >


- rir s-"1" Ki>

- |=T tfJM-'G t1 fth rvnf'Miial ■ 1"»


■ ir r-'G?'"-'

- ■¡.iw* i"'4r i,|j(it $ 7* nifioaF-araaa-' I'.»

Figure 4-6: Viewing an XML file in a Web browser.

Figure 4-6: Viewing an XML file in a Web browser.

This XML file has three root-level folders, and some of these have subfolders. You'll notice that many of the folders contain a _rels folder. These folders contain XML files that define the relationships to other parts within the package.

Following is a list of the folders in the ® sample. xlsm workbook:

■ _rels: Contains information about the package relationships.

■ docProps: Contains XML files that describe the file properties and application settings.

■ xl: This folder holds the meat of the file. The name varies with the Office document type (xl, ppt, word, and so on). You'll find several XML files that contain settings for the workbook. And if your workbook contains VBA code, it will be in a binary file with a BIN extension. The xl folder has several subfolders (some workbooks may have more or fewer subfolders, depending on the content):

o charts: Contains an XML file for each chart. This file contains the chart settings.

o chartsheets: Contains an XML file with data for each chart sheet in the workbook.

o diagrams: Contains XML files that describe the diagrams (SmartArt) in the workbook.

o drawings: Contains an XML file with data for each "drawing." Drawings include items such as buttons, charts, and images.

o media: Contains embedded media, such GIF and JPG files.

o tables: Contains an XML file with data for each table.

o theme: Contains an XML file with data about the workbook's theme.

o worksheets: Contains an XML file for each worksheet in the workbook.

Tip If you add a ZIP extension to an Excel file, you can still open it in Excel. Excel doesn't care what the file's extension is. Also, you can save a workbook with a ZIP extension. In the Save As dialog box, add a ZIP extension and then place double quotation marks around the entire file name. For example: "Myworkbook.xlsx.zip".

0 0

Post a comment