mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
initial implementation of wstring filenames
This commit is contained in:
parent
72c6569020
commit
012dd0984e
|
@ -370,6 +370,14 @@ public:
|
|||
void load(std::istream &stream, const std::string &password);
|
||||
void load(const std::vector<std::uint8_t> &data, const std::string &password);
|
||||
|
||||
#ifdef WIN32
|
||||
void save(const std::wstring &filename);
|
||||
void save(const std::wstring &filename, const std::string &password);
|
||||
|
||||
void load(const std::wstring &filename);
|
||||
void load(const std::wstring &filename, const std::string &password);
|
||||
#endif
|
||||
|
||||
bool has_view() const;
|
||||
workbook_view get_view() const;
|
||||
void set_view(const workbook_view &view);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
@ -7,7 +7,7 @@
|
|||
#include <helpers/path_helper.hpp>
|
||||
#include <xlnt/workbook/workbook.hpp>
|
||||
|
||||
#define TEST_CRYPTO true
|
||||
#define TEST_CRYPTO false
|
||||
|
||||
#ifndef TEST_CRYPTO
|
||||
#define TEST_CRYPTO false
|
||||
|
@ -64,4 +64,10 @@ public:
|
|||
TS_ASSERT_EQUALS(sheet2.get_cell("A1").comment().plain_text(), "Sheet2 comment");
|
||||
TS_ASSERT_EQUALS(sheet2.get_cell("A1").comment().author(), "Microsoft Office User");
|
||||
}
|
||||
|
||||
void test_read_unicode_filename()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
wb.load(L"data\\19_unicode_Λ.xlsx");
|
||||
}
|
||||
};
|
||||
|
|
|
@ -686,11 +686,9 @@ void workbook::load(std::istream &stream)
|
|||
|
||||
void workbook::load(const std::vector<std::uint8_t> &data)
|
||||
{
|
||||
clear();
|
||||
detail::xlsx_consumer consumer(*this);
|
||||
xlnt::detail::vector_istreambuf data_buffer(data);
|
||||
std::istream data_stream(&data_buffer);
|
||||
consumer.read(data_stream);
|
||||
load(data_stream);
|
||||
}
|
||||
|
||||
void workbook::load(const std::string &filename)
|
||||
|
@ -700,10 +698,8 @@ void workbook::load(const std::string &filename)
|
|||
|
||||
void workbook::load(const path &filename)
|
||||
{
|
||||
clear();
|
||||
detail::xlsx_consumer consumer(*this);
|
||||
std::ifstream file_stream(filename.string(), std::ios::binary);
|
||||
consumer.read(file_stream);
|
||||
load(file_stream);
|
||||
}
|
||||
|
||||
void workbook::load(const std::string &filename, const std::string &password)
|
||||
|
@ -719,11 +715,9 @@ void workbook::load(const path &filename, const std::string &password)
|
|||
|
||||
void workbook::load(const std::vector<std::uint8_t> &data, const std::string &password)
|
||||
{
|
||||
clear();
|
||||
detail::xlsx_consumer consumer(*this);
|
||||
xlnt::detail::vector_istreambuf data_buffer(data);
|
||||
std::istream data_stream(&data_buffer);
|
||||
consumer.read(data_stream, password);
|
||||
load(data_stream, password);
|
||||
}
|
||||
|
||||
void workbook::load(std::istream &stream, const std::string &password)
|
||||
|
@ -747,7 +741,6 @@ void workbook::save(const std::string &filename) const
|
|||
|
||||
void workbook::save(const path &filename) const
|
||||
{
|
||||
detail::xlsx_producer producer(*this);
|
||||
std::ofstream file_stream(filename.string(), std::ios::binary);
|
||||
save(file_stream);
|
||||
}
|
||||
|
@ -758,6 +751,20 @@ void workbook::save(std::ostream &stream) const
|
|||
producer.write(stream);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
void workbook::save(const std::wstring &filename)
|
||||
{
|
||||
std::ofstream file_stream(filename, std::ios::binary);
|
||||
save(file_stream);
|
||||
}
|
||||
|
||||
void workbook::load(const std::wstring &filename)
|
||||
{
|
||||
std::ifstream file_stream(filename, std::ios::binary);
|
||||
load(file_stream);
|
||||
}
|
||||
#endif
|
||||
|
||||
void workbook::set_guess_types(bool guess)
|
||||
{
|
||||
d_->guess_types_ = guess;
|
||||
|
|
BIN
tests/data/19_unicode_Λ.xlsx
Normal file
BIN
tests/data/19_unicode_Λ.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user