SaveAs provides a function to create or update to a spreadsheet at the provided path.
(name string, opts ...Options)
| 69 | // SaveAs provides a function to create or update to a spreadsheet at the |
| 70 | // provided path. |
| 71 | func (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. |
| 88 | func (f *File) Close() error { |