use std::fmt;
use std::future::{Future, IntoFuture};
use std::path::{Path, PathBuf};
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use laravel::http::{Download, UploadedFile};
use laravel::queue::{BatchId, ChainDispatched};
use serde::{Deserialize, Serialize};
use crate::config::ExcelConfig;
use crate::error::ExcelError;
use crate::events::GlobalListeners;
use crate::export::{Export, ExportContext};
use crate::fake::FakeState;
use crate::import::{Import, ImportContext, SheetRows, SheetWindow};
use crate::reader::{ReadOptions, ReadSheet};
use crate::sheets::SheetKey;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum Type {
Xlsx,
Csv,
Tsv,
Ods,
Xls,
Slk,
Xml,
Gnumeric,
Html,
Mpdf,
Dompdf,
Tcpdf,
}
impl fmt::Display for Type {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let name = match self {
Self::Xlsx => "Xlsx",
Self::Csv | Self::Tsv => "Csv",
Self::Ods => "Ods",
Self::Xls => "Xls",
Self::Slk => "Slk",
Self::Xml => "Xml",
Self::Gnumeric => "Gnumeric",
Self::Html => "Html",
Self::Mpdf => "Mpdf",
Self::Dompdf => "Dompdf",
Self::Tcpdf => "Tcpdf",
};
f.write_str(name)
}
}
fn extension(path: &str) -> Option<String> {
Path::new(path)
.extension()
.map(|extension| extension.to_string_lossy().to_lowercase())
.filter(|extension| !extension.trim().is_empty())
}
pub(crate) fn detect(path: &str, explicit: Option<Type>, config: &ExcelConfig) -> Result<Option<Type>, ExcelError> {
if explicit.is_some() {
return Ok(explicit);
}
let extension = extension(path).ok_or(ExcelError::NoTypeDetected)?;
Ok(config.extension_detector.get(&extension).copied())
}
pub(crate) fn detect_strict(path: &str, explicit: Option<Type>, config: &ExcelConfig) -> Result<Type, ExcelError> {
detect(path, explicit, config)?.ok_or(ExcelError::NoTypeDetected)
}
fn identify(bytes: &[u8]) -> Type {
if bytes.starts_with(b"PK") {
let head = &bytes[..bytes.len().min(200)];
if head.windows(8).any(|window| window == b"mimetype")
&& head.windows(11).any(|window| window == b"opendocumen")
{
return Type::Ods;
}
return Type::Xlsx;
}
if bytes.starts_with(&[0xD0, 0xCF, 0x11, 0xE0]) {
return Type::Xls;
}
if bytes.starts_with(&[0x1F, 0x8B]) {
return Type::Gnumeric;
}
if bytes.starts_with(b"ID;") {
return Type::Slk;
}
let head = String::from_utf8_lossy(&bytes[..bytes.len().min(2048)]).to_ascii_lowercase();
if head.contains("urn:schemas-microsoft-com:office:spreadsheet") {
return Type::Xml;
}
if head.trim_start().starts_with("<!doctype html") || head.contains("<html") || head.contains("<table") {
return Type::Html;
}
Type::Csv
}
#[derive(Clone, Default)]
pub struct ExcelState {
pub(crate) listeners: GlobalListeners,
pub(crate) fake: Arc<Mutex<Option<Arc<FakeState>>>>,
}
pub(crate) async fn state() -> ExcelState {
match laravel::container::resolve::<ExcelState>().await {
Ok(state) => (*state).clone(),
Err(_) => ExcelState::default(),
}
}
pub(crate) async fn global_listeners() -> GlobalListeners {
state().await.listeners
}
pub(crate) async fn fake() -> Option<Arc<FakeState>> {
state()
.await
.fake
.lock()
.unwrap_or_else(std::sync::PoisonError::into_inner)
.clone()
}
#[derive(Debug, Clone)]
pub enum ImportFile {
Path(String),
Uploaded {
path: PathBuf,
name: String,
},
}
impl ImportFile {
pub fn name(&self) -> &str {
match self {
Self::Path(path) => path,
Self::Uploaded { name, .. } => name,
}
}
pub(crate) async fn read(&self, disk: Option<&str>) -> laravel::Result<Vec<u8>> {
match self {
Self::Uploaded { path, .. } => Ok(std::fs::read(path)?),
Self::Path(path) => {
if disk.is_none() {
let local = Path::new(path);
let absolute = if local.is_absolute() {
local.to_path_buf()
} else {
laravel::config().app.base_path.join(local)
};
if absolute.is_file() {
let on_default_disk = match laravel::storage::default_disk() {
Ok(default) if !local.is_absolute() => default.exists(path).await.unwrap_or(false),
_ => false,
};
if !on_default_disk {
return Ok(std::fs::read(absolute)?);
}
}
}
let storage = match disk {
Some(name) => laravel::storage::disk(name)?,
None => laravel::storage::default_disk()?,
};
if !storage.exists(path).await? {
let mut log = format!("[{path}]");
if let Some(disk) = disk {
log.push_str(&format!(" ({disk})"));
}
return Err(ExcelError::UnreadableFile(format!(
"File {log} does not exist and can therefore not be imported."
))
.into());
}
Ok(storage.get_with_limit(path, u64::MAX).await?.to_vec())
}
}
}
}
impl From<&str> for ImportFile {
fn from(path: &str) -> Self {
Self::Path(path.to_owned())
}
}
impl From<String> for ImportFile {
fn from(path: String) -> Self {
Self::Path(path)
}
}
impl From<&String> for ImportFile {
fn from(path: &String) -> Self {
Self::Path(path.clone())
}
}
impl From<&UploadedFile> for ImportFile {
fn from(file: &UploadedFile) -> Self {
Self::Uploaded {
path: file.path().to_path_buf(),
name: file.client_name().to_owned(),
}
}
}
#[derive(Debug)]
pub enum Queued {
Chain(ChainDispatched),
Batch(BatchId),
Jobs(usize),
Faked,
}
type BoxedFuture<'a, T> = Pin<Box<dyn Future<Output = laravel::Result<T>> + Send + 'a>>;
pub struct Excel;
impl Excel {
pub fn download<'a, E: AsDynExport + ?Sized>(
export: &'a E,
file_name: impl Into<String>,
) -> PendingDownload<'a, E> {
PendingDownload {
export,
file_name: file_name.into(),
writer_type: None,
headers: Vec::new(),
}
}
pub fn store<'a, E: AsDynExport + ?Sized>(export: &'a E, file_path: impl Into<String>) -> PendingStore<'a, E> {
PendingStore {
export,
file_path: file_path.into(),
disk: None,
writer_type: None,
}
}
pub fn queue<'a, E: AsDynExport + ?Sized>(export: &'a E, file_path: impl Into<String>) -> PendingQueue<'a, E> {
PendingQueue {
export,
file_path: file_path.into(),
disk: None,
writer_type: None,
}
}
pub async fn raw<E: AsDynExport + ?Sized>(export: &E, writer_type: Type) -> laravel::Result<Vec<u8>> {
let export = export.__as_dyn();
if let Some(fake) = fake().await {
fake.record_raw(export);
return Ok(b"RAW-CONTENTS".to_vec());
}
let context = ExportContext::current().await;
let mut spreadsheet = crate::export::build(export, &context).await?;
write_spreadsheet(export, &mut spreadsheet, writer_type, None, &context)
}
pub fn import<'a, I: AsDynImport + ?Sized>(import: &'a I, file: impl Into<ImportFile>) -> PendingImport<'a, I> {
PendingImport {
import,
file: file.into(),
disk: None,
reader_type: None,
}
}
pub fn queue_import<'a, I: AsDynImport + ?Sized>(
import: &'a I,
file: impl Into<ImportFile>,
) -> PendingQueueImport<'a, I> {
PendingQueueImport(PendingImport {
import,
file: file.into(),
disk: None,
reader_type: None,
})
}
pub fn to_array<'a, I: AsDynImport + ?Sized>(import: &'a I, file: impl Into<ImportFile>) -> PendingRows<'a, I> {
PendingRows(PendingImport {
import,
file: file.into(),
disk: None,
reader_type: None,
})
}
pub fn to_collection<'a, I: AsDynImport + ?Sized>(
import: &'a I,
file: impl Into<ImportFile>,
) -> PendingRows<'a, I> {
Self::to_array(import, file)
}
}
#[doc(hidden)]
pub trait AsDynExport: Sync {
fn __as_dyn(&self) -> &dyn Export;
}
impl<E: Export> AsDynExport for E {
fn __as_dyn(&self) -> &dyn Export {
self
}
}
impl AsDynExport for dyn Export {
fn __as_dyn(&self) -> &dyn Export {
self
}
}
#[doc(hidden)]
pub trait AsDynImport: Sync {
fn __as_dyn(&self) -> &dyn Import;
}
impl<I: Import> AsDynImport for I {
fn __as_dyn(&self) -> &dyn Import {
self
}
}
impl AsDynImport for dyn Import {
fn __as_dyn(&self) -> &dyn Import {
self
}
}
pub(crate) fn write_spreadsheet(
export: &dyn Export,
spreadsheet: &mut crate::spreadsheet::Spreadsheet,
writer_type: Type,
file_name: Option<&str>,
context: &ExportContext,
) -> laravel::Result<Vec<u8>> {
crate::export::before_writing(export, spreadsheet, context)?;
let concerns = export.__concerns();
let mut csv = match concerns.csv_settings {
Some(settings) => settings.csv_settings(),
None => context.config.exports.csv.clone(),
};
let tsv = writer_type == Type::Tsv || file_name.is_some_and(|name| extension(name).as_deref() == Some("tsv"));
if tsv && concerns.csv_settings.is_none() {
csv.delimiter = "\t".to_owned();
}
let pre_calculate = concerns.pre_calculate_formulas || context.config.exports.pre_calculate_formulas;
Ok(crate::writer::write(spreadsheet, writer_type, &csv, pre_calculate)?)
}
pub(crate) async fn export_bytes(export: &dyn Export, file_name: &str, writer_type: Type) -> laravel::Result<Vec<u8>> {
let context = ExportContext::current().await;
let mut spreadsheet = crate::export::build(export, &context).await?;
write_spreadsheet(export, &mut spreadsheet, writer_type, Some(file_name), &context)
}
#[must_use = "await the download to build the response"]
pub struct PendingDownload<'a, E: ?Sized> {
export: &'a E,
file_name: String,
writer_type: Option<Type>,
headers: Vec<(String, String)>,
}
impl<E: ?Sized> PendingDownload<'_, E> {
pub fn writer_type(mut self, writer_type: Type) -> Self {
self.writer_type = Some(writer_type);
self
}
pub fn headers<K: Into<String>, V: Into<String>>(mut self, headers: impl IntoIterator<Item = (K, V)>) -> Self {
self.headers
.extend(headers.into_iter().map(|(name, value)| (name.into(), value.into())));
self
}
}
impl<'a, E: AsDynExport + ?Sized> IntoFuture for PendingDownload<'a, E> {
type Output = laravel::Result<Download>;
type IntoFuture = BoxedFuture<'a, Download>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let export = self.export.__as_dyn();
if let Some(fake) = fake().await {
fake.record_download(&self.file_name, export);
return Ok(Download::new(self.file_name, Vec::<u8>::new()));
}
let config = crate::config::current();
let writer_type = detect_strict(&self.file_name, self.writer_type, &config)?;
let bytes = export_bytes(export, &self.file_name, writer_type).await?;
let mut download = Download::new(self.file_name, bytes);
for (name, value) in self.headers {
download = download.with_header(name, value);
}
Ok(download)
})
}
}
#[must_use = "await the store to write the file"]
pub struct PendingStore<'a, E: ?Sized> {
export: &'a E,
file_path: String,
disk: Option<String>,
writer_type: Option<Type>,
}
impl<E: ?Sized> PendingStore<'_, E> {
pub fn disk(mut self, disk: impl Into<String>) -> Self {
self.disk = Some(disk.into());
self
}
pub fn writer_type(mut self, writer_type: Type) -> Self {
self.writer_type = Some(writer_type);
self
}
}
impl<'a, E: AsDynExport + ?Sized> IntoFuture for PendingStore<'a, E> {
type Output = laravel::Result<bool>;
type IntoFuture = BoxedFuture<'a, bool>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let export = self.export.__as_dyn();
if export.__concerns().should_queue.is_some() {
crate::queue::queue_export(export, &self.file_path, self.disk.as_deref(), self.writer_type).await?;
return Ok(true);
}
if let Some(fake) = fake().await {
fake.record_store(self.disk.as_deref(), &self.file_path, export);
return Ok(true);
}
let config = crate::config::current();
let writer_type = detect_strict(&self.file_path, self.writer_type, &config)?;
let bytes = export_bytes(export, &self.file_path, writer_type).await?;
let disk = match &self.disk {
Some(name) => laravel::storage::disk(name)?,
None => laravel::storage::default_disk()?,
};
disk.put(&self.file_path, bytes).await?;
Ok(true)
})
}
}
#[must_use = "await the queue to dispatch the jobs"]
pub struct PendingQueue<'a, E: ?Sized> {
export: &'a E,
file_path: String,
disk: Option<String>,
writer_type: Option<Type>,
}
impl<E: ?Sized> PendingQueue<'_, E> {
pub fn disk(mut self, disk: impl Into<String>) -> Self {
self.disk = Some(disk.into());
self
}
pub fn writer_type(mut self, writer_type: Type) -> Self {
self.writer_type = Some(writer_type);
self
}
}
impl<'a, E: AsDynExport + ?Sized> IntoFuture for PendingQueue<'a, E> {
type Output = laravel::Result<Queued>;
type IntoFuture = BoxedFuture<'a, Queued>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
crate::queue::queue_export(
self.export.__as_dyn(),
&self.file_path,
self.disk.as_deref(),
self.writer_type,
)
.await
})
}
}
#[must_use = "await the import to read the file"]
pub struct PendingImport<'a, I: ?Sized> {
import: &'a I,
file: ImportFile,
disk: Option<String>,
reader_type: Option<Type>,
}
impl<I: ?Sized> PendingImport<'_, I> {
pub fn disk(mut self, disk: impl Into<String>) -> Self {
self.disk = Some(disk.into());
self
}
pub fn reader_type(mut self, reader_type: Type) -> Self {
self.reader_type = Some(reader_type);
self
}
}
impl<'a, I: AsDynImport + ?Sized> IntoFuture for PendingImport<'a, I> {
type Output = laravel::Result<Option<Queued>>;
type IntoFuture = BoxedFuture<'a, Option<Queued>>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let import = self.import.__as_dyn();
if let Some(fake) = fake().await {
if import.__concerns().should_queue.is_some() {
fake.record_queued_import(self.disk.as_deref(), self.file.name(), import);
return Ok(Some(Queued::Faked));
}
fake.record_import(self.disk.as_deref(), self.file.name(), import);
return Ok(None);
}
read(import, &self.file, self.disk.as_deref(), self.reader_type).await
})
}
}
#[must_use = "await the import to dispatch its jobs"]
pub struct PendingQueueImport<'a, I: ?Sized>(PendingImport<'a, I>);
impl<I: ?Sized> PendingQueueImport<'_, I> {
pub fn disk(self, disk: impl Into<String>) -> Self {
Self(self.0.disk(disk))
}
pub fn reader_type(self, reader_type: Type) -> Self {
Self(self.0.reader_type(reader_type))
}
}
impl<'a, I: AsDynImport + ?Sized> IntoFuture for PendingQueueImport<'a, I> {
type Output = laravel::Result<Queued>;
type IntoFuture = BoxedFuture<'a, Queued>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
if self.0.import.__as_dyn().__concerns().should_queue.is_none() {
return Err(ExcelError::NotQueueable.into());
}
self.0.await?.ok_or_else(|| ExcelError::NotQueueable.into())
})
}
}
#[must_use = "await the rows to read the file"]
pub struct PendingRows<'a, I: ?Sized>(PendingImport<'a, I>);
impl<I: ?Sized> PendingRows<'_, I> {
pub fn disk(self, disk: impl Into<String>) -> Self {
Self(self.0.disk(disk))
}
pub fn reader_type(self, reader_type: Type) -> Self {
Self(self.0.reader_type(reader_type))
}
}
impl<'a, I: AsDynImport + ?Sized> IntoFuture for PendingRows<'a, I> {
type Output = laravel::Result<SheetRows>;
type IntoFuture = BoxedFuture<'a, SheetRows>;
fn into_future(self) -> Self::IntoFuture {
Box::pin(async move {
let pending = self.0;
let import = pending.import.__as_dyn();
if let Some(fake) = fake().await {
fake.record_import(pending.disk.as_deref(), pending.file.name(), import);
return Ok(SheetRows::new());
}
to_rows(import, &pending.file, pending.disk.as_deref(), pending.reader_type).await
})
}
}
pub(crate) async fn load(
import: &dyn Import,
bytes: &[u8],
file_name: &str,
reader_type: Option<Type>,
config: &ExcelConfig,
) -> laravel::Result<(Type, Vec<ReadSheet>)> {
let kind = match detect(file_name, reader_type, config)? {
Some(kind) => kind,
None => identify(bytes),
};
let concerns = import.__concerns();
let csv = match concerns.csv_settings {
Some(settings) => settings.csv_import_settings(),
None => config.imports.csv.clone(),
};
let options = ReadOptions {
csv,
ignore_empty: config.imports.ignore_empty,
binder: concerns.binder(config),
tsv: extension(file_name).as_deref() == Some("tsv"),
style_information: crate::import::requires_style_information(import),
};
let mut sheets = crate::reader::read(bytes, kind, &options)?;
if let Some(filter) = concerns.read_filter {
for sheet in &mut sheets {
sheet.filter(filter);
}
}
Ok((kind, sheets))
}
async fn read(
import: &dyn Import,
file: &ImportFile,
disk: Option<&str>,
reader_type: Option<Type>,
) -> laravel::Result<Option<Queued>> {
let concerns = import.__concerns();
let queued = concerns.should_queue.is_some();
let chunked = concerns.chunk_reading.is_some();
drop(concerns);
if queued && !chunked {
return Err(ExcelError::QueueWithoutChunkReading.into());
}
let context = ImportContext::current().await;
let bytes = file.read(disk).await?;
if chunked {
return crate::queue::read_in_chunks(import, bytes, file.name(), reader_type, &context).await;
}
let result: laravel::Result<()> = async {
let (_, mut sheets) = load(import, &bytes, file.name(), reader_type, &context.config).await?;
let owned = match import.__concerns().multiple_sheets {
Some(multiple) => multiple.sheets().imports(),
None => Vec::new(),
};
let pairs: Vec<(SheetKey, usize, &dyn Import)> = crate::import::sheet_imports(import, &sheets, &owned)?
.into_iter()
.collect();
let total_rows = crate::import::total_rows(&sheets);
crate::import::before_import(import, &total_rows, &context.listeners)?;
crate::import::transaction(&context.config, async || {
for (_, index, sheet_import) in &pairs {
let start_row = sheet_import.__concerns().start_row_number();
let window = SheetWindow {
start_row,
end_row: None,
chunk_offset: None,
};
crate::import::import_sheet(*sheet_import, &mut sheets[*index], window, &context).await?;
}
Ok(())
})
.await?;
crate::import::after_import(import, &total_rows, &context.listeners)
}
.await;
if let Err(error) = &result {
crate::import::import_failed(import, error, &context.listeners);
}
result.map(|()| None)
}
async fn to_rows(
import: &dyn Import,
file: &ImportFile,
disk: Option<&str>,
reader_type: Option<Type>,
) -> laravel::Result<SheetRows> {
let context = ImportContext::current().await;
let bytes = file.read(disk).await?;
let (_, sheets) = load(import, &bytes, file.name(), reader_type, &context.config).await?;
let owned = match import.__concerns().multiple_sheets {
Some(multiple) => multiple.sheets().imports(),
None => Vec::new(),
};
let pairs = crate::import::sheet_imports(import, &sheets, &owned)?;
let total_rows = crate::import::total_rows(&sheets);
crate::import::before_import(import, &total_rows, &context.listeners)?;
let mut result = SheetRows::new();
for (key, index, sheet_import) in pairs {
let start_row = sheet_import.__concerns().start_row_number();
let middleware = context.config.imports.cell_middleware.clone();
let sheet = crate::import::SheetImport {
sheet: &sheets[index],
start_row,
end_row: None,
chunk_offset: None,
middleware: &middleware,
listeners: &context.listeners,
ignore_empty: context.config.imports.ignore_empty,
};
let rows = crate::import::to_rows(&sheet, sheet_import).await?;
result.insert(key, rows);
}
crate::import::after_import(import, &total_rows, &context.listeners)?;
Ok(result)
}
pub trait Exportable: Export + Sized {
fn file_name(&self) -> Option<String> {
None
}
fn writer_type(&self) -> Option<Type> {
None
}
fn headers(&self) -> Vec<(String, String)> {
Vec::new()
}
fn file_path(&self) -> Option<String> {
None
}
fn disk(&self) -> Option<String> {
None
}
fn download(&self, file_name: Option<&str>) -> impl Future<Output = laravel::Result<Download>> + Send {
async move {
let file_name = file_name
.map(str::to_owned)
.or_else(|| self.file_name())
.ok_or(ExcelError::NoFilenameGiven)?;
let mut pending = Excel::download(self, file_name).headers(self.headers());
if let Some(writer_type) = self.writer_type() {
pending = pending.writer_type(writer_type);
}
pending.await
}
}
fn store(&self, file_path: Option<&str>) -> impl Future<Output = laravel::Result<bool>> + Send {
async move {
let file_path = file_path
.map(str::to_owned)
.or_else(|| self.file_path())
.ok_or(ExcelError::NoExportFilePathGiven)?;
let mut pending = Excel::store(self, file_path);
if let Some(disk) = self.disk() {
pending = pending.disk(disk);
}
if let Some(writer_type) = self.writer_type() {
pending = pending.writer_type(writer_type);
}
pending.await
}
}
fn queue(&self, file_path: Option<&str>) -> impl Future<Output = laravel::Result<Queued>> + Send {
async move {
let file_path = file_path
.map(str::to_owned)
.or_else(|| self.file_path())
.ok_or(ExcelError::NoExportFilePathGiven)?;
let mut pending = Excel::queue(self, file_path);
if let Some(disk) = self.disk() {
pending = pending.disk(disk);
}
if let Some(writer_type) = self.writer_type() {
pending = pending.writer_type(writer_type);
}
pending.await
}
}
fn raw(&self, writer_type: Option<Type>) -> impl Future<Output = laravel::Result<Vec<u8>>> + Send {
async move {
let writer_type = writer_type
.or_else(|| self.writer_type())
.ok_or(ExcelError::NoTypeDetected)?;
Excel::raw(self, writer_type).await
}
}
}
pub trait Importable: Import + Sized {
fn file_path(&self) -> Option<String> {
None
}
fn disk(&self) -> Option<String> {
None
}
fn reader_type(&self) -> Option<Type> {
None
}
fn import(&self, file: Option<ImportFile>) -> impl Future<Output = laravel::Result<Option<Queued>>> + Send {
async move {
let file = file
.or_else(|| self.file_path().map(ImportFile::Path))
.ok_or(ExcelError::NoImportFilePathGiven)?;
let mut pending = Excel::import(self, file);
if let Some(disk) = self.disk() {
pending = pending.disk(disk);
}
if let Some(reader_type) = self.reader_type() {
pending = pending.reader_type(reader_type);
}
pending.await
}
}
fn to_array(&self, file: Option<ImportFile>) -> impl Future<Output = laravel::Result<SheetRows>> + Send {
async move {
let file = file
.or_else(|| self.file_path().map(ImportFile::Path))
.ok_or(ExcelError::NoImportFilePathGiven)?;
let mut pending = Excel::to_array(self, file);
if let Some(disk) = self.disk() {
pending = pending.disk(disk);
}
if let Some(reader_type) = self.reader_type() {
pending = pending.reader_type(reader_type);
}
pending.await
}
}
fn to_collection(&self, file: Option<ImportFile>) -> impl Future<Output = laravel::Result<SheetRows>> + Send {
self.to_array(file)
}
fn queue(&self, file: Option<ImportFile>) -> impl Future<Output = laravel::Result<Queued>> + Send {
async move {
let file = file
.or_else(|| self.file_path().map(ImportFile::Path))
.ok_or(ExcelError::NoImportFilePathGiven)?;
let mut pending = Excel::queue_import(self, file);
if let Some(disk) = self.disk() {
pending = pending.disk(disk);
}
if let Some(reader_type) = self.reader_type() {
pending = pending.reader_type(reader_type);
}
pending.await
}
}
}