解析Wor文件

时间:2013-03-05 09:39:39

标签: c# .net

我正在开发一个项目,该项目要求我解析.Wor文件并仅拉出绘图命令。基本上任何Create命令。我该如何解析这个文件?我的问题是不同的Create类型将遵循不同的结构,例如Rect将是

Create Rect (835371.97,833248.31) (836323.1,833370.63)
    Pen (1,2,0) 
    Brush (2,16777215)

和一个地区将是:

Create Region  1
  41
(836450.91,833741.68)
(836420.68,833758.17)
(836389.07,833769.17)
(836340.97,833780.17)
(836286,833784.29)

在两个例子中,(x,y)坐标都是我要解析的。

这是一个示例文件:

!Workspace
!Version 600
!Charset WindowsLatin1
Open Table "USA\USA_MAPS\USZIPBDY" As USZIPBDY Interactive
Open Table "USA\USA_MAPS\LANDMRKS" As LANDMRKS Interactive
Open Table "USA\USA_MAPS\US_CNTY" As US_CNTY Interactive
Cut here ……………………….Cut here
    Map From USCTY_8K,USCTY153,USA_CAPS,LANDMRKS,US_HIWAY,USZIPBDY,USA,US_CNTY
      Position (0.0520833,0.0520833) Units "in"
      Width 6.14583 Units "in" Height 4.47917 Units "in"
    Set Window FrontWindow() ScrollBars On Autoscroll On
    Set Map
      CoordSys Earth Projection 1, 33
      Center (-120.7334628,47.40479464)
      Zoom 434.4235605 Units "mi"
      Preserve Zoom Display Zoom
      Distance Units "mi" Area Units "sq mi" XY Units "degree"
    Set Map
      Layer 1
        Display Off
        Global   Symbol (35,0,12)  
        Label Line Arrow Position Right Font ("Arial",0,9,0) Pen (1,2,0)
          With City
          Parallel On Auto Off Overlap Off Duplicates On Offset 2
          Visibility On
      Layer 2
        Display Off
        Global   Symbol (35,0,12)  
        Label Line Arrow Position Right Font ("Arial",0,9,0) Pen (1,2,0)
          With City
          Parallel On Auto Off Overlap Off Duplicates On Offset 2
          Visibility On
      Layer 3
        Display Off
        Global   Symbol (35,0,12)  
        Label Line Arrow Position Right Font ("Arial",0,9,0) Pen (1,2,0)
          With Capital
          Parallel On Auto Off Overlap Off Duplicates On Offset 2
          Visibility On
    Cut here ……………………. Cut here
      Layer 7
        Display Global
        Global Pen (2,2,0)  Brush (1,16777215,16777215)  Symbol (35,0,12)  
        Label Line None Position Center Font ("Arial",257,12,0,16777215) Pen (1,2,0)
          With State_Name
          Parallel On Auto On Overlap On Duplicates On Offset 2
          Visibility On
        Activate Using URL On Objects Relative Path Off
      Layer 8
        Display Global
        Global  Brush (2,16772272,16777215)  Symbol (35,0,12)  
        Label Line None Position Center Font ("Arial",257,8,11579568,16777215) Pen (1,2,0)
          With County
          Parallel On Auto On Overlap On Duplicates On Offset 2
          Visibility On
    Layout
      Position (4.69792,3.19792) Units "in"
      Width 5.29167 Units "in" Height 3.32292 Units "in"
      Set CoordSys Layout Units "in"
      Create Frame (3.3132,1.6889) (39.5153,27.7993)
        Pen (2,63,0)
        Brush (2,9502608,16777215)
        Title "USCTY_8K,USCTY153,...,US_CNTY Map"
        FillFrame On
      Create Text
        "Washington State, USE"
        (16.7688,29.4451) (24.1389,30.2285)
        Font ("Arial",1,48,0)

      Create Region  1
      41
      (836450.91,833741.68)
      (836420.68,833758.17)
      (836389.07,833769.17)
      (836340.97,833780.17)
      (836286,833784.29)

  Create Text
    "Mapsheet#  15"
    (17.8021,31.5764) (22.2118,32.3431)
    Font ("Arial",0,48,0)

  Set Layout Ruler On Pagebreaks On Frame Contents Active
  Zoom 8.54867 Center (28.4564,16.9983) Extents To Fit
  Set Window FrontWindow() Autoscroll On
  Set CoordSys Earth

0 个答案:

没有答案