MCPcopy
hub / github.com/qax-os/excelize / NewFile

Function NewFile

file.go:31–56  ·  view source on GitHub ↗

NewFile provides a function to create new file by default template. For example: f := NewFile()

(opts ...Options)

Source from the content-addressed store, hash-verified

29//
30// f := NewFile()
31func NewFile(opts ...Options) *File {
32 f := newFile()
33 f.Pkg.Store(defaultXMLPathRels, []byte(xml.Header+templateRels))
34 f.Pkg.Store(defaultXMLPathDocPropsApp, []byte(xml.Header+templateDocpropsApp))
35 f.Pkg.Store(defaultXMLPathDocPropsCore, []byte(xml.Header+templateDocpropsCore))
36 f.Pkg.Store(defaultXMLPathWorkbookRels, []byte(xml.Header+templateWorkbookRels))
37 f.Pkg.Store(defaultXMLPathTheme, []byte(xml.Header+templateTheme))
38 f.Pkg.Store(defaultXMLPathSheet, []byte(xml.Header+templateSheet))
39 f.Pkg.Store(defaultXMLPathStyles, []byte(xml.Header+templateStyles))
40 f.Pkg.Store(defaultXMLPathWorkbook, []byte(xml.Header+templateWorkbook))
41 f.Pkg.Store(defaultXMLPathContentTypes, []byte(xml.Header+templateContentTypes))
42 f.SheetCount = 1
43 f.CalcChain, _ = f.calcChainReader()
44 f.ContentTypes, _ = f.contentTypesReader()
45 f.Styles, _ = f.stylesReader()
46 f.WorkBook, _ = f.workbookReader()
47 f.Relationships = sync.Map{}
48 rels, _ := f.relsReader(defaultXMLPathWorkbookRels)
49 f.Relationships.Store(defaultXMLPathWorkbookRels, rels)
50 f.sheetMap["Sheet1"] = defaultXMLPathSheet
51 ws, _ := f.workSheetReader("Sheet1")
52 f.Sheet.Store(defaultXMLPathSheet, ws)
53 f.Theme, _ = f.themeReader()
54 f.options = f.getOptions(opts...)
55 return f
56}
57
58// Save provides a function to override the spreadsheet with origin path.
59func (f *File) Save(opts ...Options) error {

Callers 15

TestStyleFillFunction · 0.85
TestSetConditionalFormatFunction · 0.85
TestNewStyleFunction · 0.85
TestConditionalStyleFunction · 0.85
TestGetDefaultFontFunction · 0.85
TestSetDefaultFontFunction · 0.85
TestStylesReaderFunction · 0.85
TestThemeReaderFunction · 0.85
TestSetCellStyleFunction · 0.85
TestGetStyleIDFunction · 0.85

Calls 9

newFileFunction · 0.85
calcChainReaderMethod · 0.80
contentTypesReaderMethod · 0.80
stylesReaderMethod · 0.80
workbookReaderMethod · 0.80
relsReaderMethod · 0.80
workSheetReaderMethod · 0.80
themeReaderMethod · 0.80
getOptionsMethod · 0.80

Tested by 15

TestStyleFillFunction · 0.68
TestSetConditionalFormatFunction · 0.68
TestNewStyleFunction · 0.68
TestConditionalStyleFunction · 0.68
TestGetDefaultFontFunction · 0.68
TestSetDefaultFontFunction · 0.68
TestStylesReaderFunction · 0.68
TestThemeReaderFunction · 0.68
TestSetCellStyleFunction · 0.68
TestGetStyleIDFunction · 0.68