xlnt
streaming_workbook_reader.hpp
1 // Copyright (c) 2014-2022 Thomas Fussell
2 // Copyright (c) 2010-2015 openpyxl
3 // Copyright (c) 2024 xlnt-community
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE
22 //
23 // @license: http://www.opensource.org/licenses/mit-license.php
24 // @author: see AUTHORS file
25 #pragma once
26 
27 #include <functional>
28 #include <iostream>
29 #include <memory>
30 #include <string>
31 #include <vector>
32 
33 #include <xlnt/xlnt_config.hpp>
34 
35 namespace xml {
36 class parser;
37 }
38 
39 namespace xlnt {
40 
41 class cell;
42 template <typename T>
43 class optional;
44 class path;
45 class workbook;
46 class worksheet;
47 
48 namespace detail {
49 class xlsx_consumer;
50 }
51 
56 {
57 public:
60 
65  void close();
66 
67  bool has_cell();
68 
73  cell read_cell();
74 
75  bool has_worksheet(const std::string &name);
76 
81  void begin_worksheet(const std::string &name);
82 
88  worksheet end_worksheet();
89 
94  void open(const std::vector<std::uint8_t> &data);
95 
100  void open(const std::string &filename);
101 
102 #ifdef _MSC_VER
103  void open(const std::wstring &filename);
108 #endif
109 
114  void open(const path &filename);
115 
120  void open(std::istream &stream);
121 
126  void open(std::unique_ptr<std::streambuf> &&buffer);
127 
131  std::vector<std::string> sheet_titles();
132 
133 private:
134  std::string worksheet_rel_id_;
135  std::unique_ptr<detail::xlsx_consumer> consumer_;
136  std::unique_ptr<workbook> workbook_;
137  std::unique_ptr<std::istream> stream_;
138  std::unique_ptr<std::streambuf> stream_buffer_;
139  std::unique_ptr<std::istream> part_stream_;
140  std::unique_ptr<std::streambuf> part_stream_buffer_;
141  std::unique_ptr<xml::parser> parser_;
142 };
143 
144 } // namespace xlnt
Enumerates the possible types a cell can be determined by it&#39;s current value.
Definition: cell.hpp:37
A worksheet is a 2D array of cells starting with cell A1 in the top-left corner and extending indefin...
Definition: worksheet.hpp:77
Definition: spreadsheet_drawing.hpp:31
Describes a unit of data in a worksheet at a specific coordinate and its associated properties...
Definition: cell.hpp:84
Encapsulates a path that points to location in a filesystem.
Definition: path.hpp:38
workbook is the container for all other parts of the document.
Definition: streaming_workbook_reader.hpp:55