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

Method SaveAs

file.go:71–85  ·  view source on GitHub ↗

SaveAs provides a function to create or update to a spreadsheet at the provided path.

(name string, opts ...Options)

Source from the content-addressed store, hash-verified

69// SaveAs provides a function to create or update to a spreadsheet at the
70// provided path.
71func (f *File) SaveAs(name string, opts ...Options) error {
72 if countUTF16String(name) > MaxFilePathLength {
73 return ErrMaxFilePathLength
74 }
75 f.Path = name
76 if _, ok := supportedContentTypes[strings.ToLower(filepath.Ext(f.Path))]; !ok {
77 return ErrWorkbookFileFormat
78 }
79 file, err := os.OpenFile(filepath.Clean(name), os.O_WRONLY|os.O_TRUNC|os.O_CREATE, os.ModePerm)
80 if err != nil {
81 return err
82 }
83 defer file.Close()
84 return f.Write(file, opts...)
85}
86
87// Close closes and cleanup the open temporary file for the spreadsheet.
88func (f *File) Close() error {

Callers 15

TestStyleFillFunction · 0.95
TestNewStyleFunction · 0.95
TestGetNumFmtIDFunction · 0.95
TestAddChartFunction · 0.95
TestAddChartSheetFunction · 0.95
TestFormControlFunction · 0.95
TestAddHeaderFooterImageFunction · 0.95
BenchmarkWriteFunction · 0.95
TestZip64Function · 0.95

Calls 3

WriteMethod · 0.95
countUTF16StringFunction · 0.85
CloseMethod · 0.65

Tested by 15

TestStyleFillFunction · 0.76
TestNewStyleFunction · 0.76
TestGetNumFmtIDFunction · 0.76
TestAddChartFunction · 0.76
TestAddChartSheetFunction · 0.76
TestFormControlFunction · 0.76
TestAddHeaderFooterImageFunction · 0.76
BenchmarkWriteFunction · 0.76
TestZip64Function · 0.76