-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/MortalreminderPT/edit-xlsx
- Loading branch information
Showing
24 changed files
with
272 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use edit_xlsx::{Workbook, WorkbookResult}; | ||
|
||
fn main() -> WorkbookResult<()> { | ||
let mut workbook = Workbook::from_path("examples/comments_test.xlsx")?; | ||
let worksheet = workbook.get_worksheet(1)?; | ||
workbook.save_as("examples/comments_test_saved.xlsx")?; | ||
Ok(()) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
pub(crate) mod vml_drawing; | ||
|
||
use std::io; | ||
use std::path::Path; | ||
use quick_xml::{de, se}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use std::io; | ||
use std::path::Path; | ||
use quick_xml::{de, se}; | ||
use serde::{Deserialize, Serialize}; | ||
use crate::file::{XlsxFileReader, XlsxFileType, XlsxFileWriter}; | ||
use crate::xml::namespaces::office as o; | ||
use crate::xml::namespaces::vml as v; | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
pub(crate) struct VmlDrawing { | ||
#[serde(rename(serialize = "@xmlns:v", deserialize = "@xmlns:v"))] | ||
xmlns_v: String, | ||
#[serde(rename(serialize = "@xmlns:o", deserialize = "@xmlns:o"))] | ||
xmlns_o: String, | ||
#[serde(rename(serialize = "@xmlns:x", deserialize = "@xmlns:x"))] | ||
xmlns_x: String, | ||
#[serde(rename(serialize = "o:shapelayout", deserialize = "shapelayout"))] | ||
shapelayout: o::ShapeLayout, | ||
#[serde(rename(serialize = "v:shapetype", deserialize = "shapetype"))] | ||
shapetype: v::ShapeType, | ||
#[serde(rename(serialize = "v:shape", deserialize = "shape"))] | ||
shape: v::Shape, | ||
} | ||
|
||
impl VmlDrawing { | ||
pub(crate) fn from_path<P: AsRef<Path>>(file_path: P, drawing_id: u32) -> io::Result<VmlDrawing> { | ||
let mut file = XlsxFileReader::from_path(file_path, XlsxFileType::VmlDrawings(drawing_id))?; | ||
let mut xml = String::new(); | ||
file.read_to_string(&mut xml).unwrap(); | ||
let drawing: VmlDrawing = de::from_str(&xml).unwrap(); | ||
Ok(drawing) | ||
} | ||
|
||
pub(crate) fn save<P: AsRef<Path>>(&self, file_path: P, drawing_id: u32) { | ||
let xml = se::to_string_with_root("xml", &self).unwrap(); | ||
// let xml = format!("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n{}", xml); | ||
let mut file = XlsxFileWriter::from_path(file_path, XlsxFileType::VmlDrawings(drawing_id)).unwrap(); | ||
file.write_all(xml.as_ref()).unwrap(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pub(crate) mod excel; | ||
pub(crate) mod vml; | ||
pub(crate) mod office; | ||
mod xdr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// | ||
/// xmlns:x="urn:schemas-microsoft-com:office:excel" | ||
/// | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
#[serde(rename(serialize = "x:ClientData", deserialize = "ClientData"))] | ||
pub(crate) struct ClientData { | ||
#[serde(rename(serialize = "@ObjectType", deserialize = "@ObjectType"))] | ||
object_type: String, | ||
#[serde(rename(serialize = "x:MoveWithCells", deserialize = "MoveWithCells"))] | ||
move_with_cells: MoveWithCells, | ||
#[serde(rename(serialize = "x:SizeWithCells", deserialize = "SizeWithCells"))] | ||
size_with_cells: SizeWithCells, | ||
#[serde(rename(serialize = "x:Anchor", deserialize = "Anchor"))] | ||
anchor: Anchor, | ||
#[serde(rename(serialize = "x:Row", deserialize = "Row"))] | ||
row: Row, | ||
#[serde(rename(serialize = "x:Column", deserialize = "Column"))] | ||
column: Column, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
struct MoveWithCells {} | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
struct SizeWithCells { | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
struct Anchor { | ||
#[serde(rename = "$value")] | ||
value: String,// Vec<u32>, | ||
} | ||
#[derive(Debug, Deserialize, Serialize)] | ||
#[serde(rename(serialize = "x:AutoFill", deserialize = "AutoFill"))] | ||
struct AutoFill { | ||
#[serde(rename = "$value")] | ||
value: bool, | ||
} | ||
#[derive(Debug, Deserialize, Serialize)] | ||
struct Row { | ||
#[serde(rename = "$value")] | ||
value: u32, | ||
} | ||
#[derive(Debug, Deserialize, Serialize)] | ||
struct Column { | ||
#[serde(rename = "$value")] | ||
value: u32, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
// #[serde(rename(serialize = "o:shapelayout", deserialize = "shapelayout"))] | ||
pub(crate) struct ShapeLayout { | ||
#[serde(rename(serialize = "@v:ext", deserialize = "@ext"))] | ||
v_ext: String, | ||
#[serde(rename(serialize = "o:idmap", deserialize = "idmap"))] | ||
id_map: IdMap, | ||
} | ||
|
||
#[derive(Debug, Deserialize, Serialize)] | ||
// #[serde(rename(serialize = "o:idmap", deserialize = "idmap"))] | ||
struct IdMap { | ||
#[serde(rename(serialize = "@v:ext", deserialize = "@ext"))] | ||
v_ext: String, | ||
#[serde(rename = "@data")] | ||
data: u32, | ||
} |
Oops, something went wrong.