ole

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NONE = iota
	WORDDOCUMENT
	XLS
	PPT
)

文件类型

View Source
const (
	//有数据的类型
	RT_TEXT_CHARS_ATOM = uint16(4000)
	RT_TEXT_BYTES_ATOM = uint16(4008)
	RT_CSTRING         = uint16(4026)

	//不需要移动的类型
	RT_DOCUMENT               = uint16(1000)
	RT_SLIDE_BASE             = uint16(1004)
	RT_SLIDE                  = uint16(1006)
	RT_DRAWING                = uint16(1036)
	RT_LIST                   = uint16(2000)
	RT_SLIDE_LIST_WITH_TEXT   = uint16(4080)
	OFFICE_ART_DG_CONTAINER   = uint16(61442)
	OFFICE_ART_SPGR_CONTAINER = uint16(61443)
	OFFICE_ART_SP_CONTAINER   = uint16(61444)
	OFFICE_ART_CLIENT_TEXTBOX = uint16(0xF00D) //61453
)
View Source
const (
	XLS_BOF          = 0x809
	XLS_CODEPAGE     = 0x42
	XLS_DATE_1904    = 0x22
	XLS_FILEPASS     = 0x2F
	XLS_FORMAT       = 0x41E
	XLS_FORMULA      = 0x06
	XLS_INTEGER_CELL = 0x202
	XLS_RSTRING      = 0xD6

	//Globals
	XLS_SHEET    = 0x85
	XLS_CONTINUE = 0x3C
	XLS_SST      = 0xFC

	XLS_STRING = 0x207
	XLS_XF     = 0xE0
	XLS_EOF    = 0x0A
)

xls结构中的几个关键值

View Source
const (
	BOF_BIFF_2       = 0x009
	BOF_BIFF_3       = 0x209
	BOF_BIFF_4       = 0x0409
	BOF_BIFF_5_AND_8 = XLS_BOF
)

xls版本

View Source
const (
	//sheet
	XLS_LABEL_SST = 0xFD
	XLS_LABEL     = 0x204
	XLS_BLANK     = 0x201
	XLS_BOOLERR   = 0x205
	XLS_NUMBER    = 0x203
	XLS_MULBLANK  = 0xBE
	XLS_RK        = 0x27E
	XLS_MULRK     = 0xBD
)
View Source
const MaxFileNum = 3000

Variables

View Source
var DIFSECT = []byte{0xFC, 0xFF, 0xFF, 0xFF}
View Source
var DefaultDIFATEntries = uint32(109)
View Source
var ENDOFCHAIN = []byte{0xFE, 0xFF, 0xFF, 0xFF}
View Source
var EntrySize = 128

每个fat大小

View Source
var FATSECT = []byte{0xFD, 0xFF, 0xFF, 0xFF}
View Source
var FREESECT = []byte{0xFF, 0xFF, 0xFF, 0xFF}
View Source
var MAXREGSECT = []byte{0xFA, 0xFF, 0xFF, 0xFF}
View Source
var MajorVersion3 = []byte{0x03, 0x00}

主要版本为3,扇区大小为512

View Source
var MajorVersion4 = []byte{0x04, 0x00}

主要版本为4,扇区大小为4096

View Source
var NOTAPP = []byte{0xFB, 0xFF, 0xFF, 0xFF}
View Source
var Olesign = []byte{0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1}

ole复合文件标识

Functions

func BytesToUints16

func BytesToUints16(b []byte) (res []uint16)

Types

type DataCallBackFunc

type DataCallBackFunc func(string, string) bool

type Directory

type Directory struct {
	EleName        [64]byte
	CbEleNameLenth [2]byte
	ObjectType     byte
	ColorFlag      byte
	LeftSiblingID  [4]byte
	RightSiblingID [4]byte
	ChildID        [4]byte
	CLSID          [16]byte
	UserFlags      [4]byte
	CreationTime   [8]byte
	ModifiedTime   [8]byte
	StartSect      [4]byte
	StreamSize     [8]byte
}

128字节

type FIB

type FIB struct {
	WIdent [2]byte
	// 193
	NFib   uint16
	Unused [2]byte
	Lid    [2]byte
	PnNext [2]byte
	// A-是否是dot文件 C-是否为复杂模式	D-是否包含图片
	AE byte
	// F-是否加密 G-存储表(0/1)
	FM        byte
	NFibBack  [2]byte
	LKey      [4]byte
	Envr      byte
	NS        byte
	Reserved3 [2]byte
	Reserved4 [2]byte
	Fcmin     uint32
	Reserved6 [4]byte

	Csw       [2]byte
	FlibRgW97 [28]byte
	Cslw      [2]byte

	CbMac       [4]byte
	Reserved1_2 [8]byte
	// 正文字数
	CcpText uint32
	// 页脚字数
	CcpFtn uint32
	// 页眉字数
	CcpHdd uint32
	// 批注字数
	CcpMcr uint32
	// 尾注字数
	CcpAtn uint32
	CcpEdn uint32
	// 文本框字数
	CcpTxbx uint32
	// 页眉文本框字数
	CcpHdrTxbx uint32

	Reserved4_14 [44]byte
}

WordDocument 结构

type Header struct {
	HeaderSignature            [8]byte
	HeaderCLSID                [16]byte
	MinorVersion               [2]byte
	MajorVersion               [2]byte
	ByteOrder                  [2]byte
	SectorShift                uint16
	MiniSectorShift            uint16
	Reserved                   [6]byte
	NumberDirectorySectors     [4]byte
	NumberFATSectors           [4]byte
	DirSect                    [4]byte
	TransactionSignatureNumber [4]byte
	MiniStreamCutoffSize       [4]byte
	MiniFatSect                [4]byte
	NumberMiniFATSectors       [4]byte
	DifatSect                  [4]byte
	NumberDIFATSectors         [4]byte
	DIFAT                      [436]byte
}

文件头 512

type OleInfo

type OleInfo struct {

	//类型
	Type string
	// contains filtered or unexported fields
}

func (*OleInfo) GetFileHeader

func (ole *OleInfo) GetFileHeader(fileReadSeeker io.ReadSeeker) error

读取文件头

func (*OleInfo) GetHandle

func (ole *OleInfo) GetHandle(fileReadSeeker io.ReadSeeker) error

判断是否是office97

func (*OleInfo) GetObjectData

func (ole *OleInfo) GetObjectData(callBack DataCallBackFunc) (err error)

获取结构

func (*OleInfo) OpenFile

func (ole *OleInfo) OpenFile(filename string) (err error)

打开文件

func (*OleInfo) Read

func (ole *OleInfo) Read(fileReadSeeker io.ReadSeeker) (err error)

读取文件

type PCD

type PCD struct {
	Fnordr [2]byte
	Fc     [4]byte
	Prm    [2]byte
}

type SHEETSTRUCT

type SHEETSTRUCT struct {
	// contains filtered or unexported fields
}

sheet结构(名字+偏移量)

type Sector

type Sector struct {
	SectorSize uint32
	Data       []byte
}

func NewMiniFatSector

func NewMiniFatSector(header *Header) Sector

MiniFat

func NewSector

func NewSector(header *Header) Sector

FAT

type XlsInfo

type XlsInfo struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL