Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/structs/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,14 @@ pub struct Cell {
hyperlink: Option<Hyperlink>,
}
impl Cell {
pub fn get_cell_value(&self) -> &CellValue {
pub(crate) fn get_cell_value(&self) -> &CellValue {
&self.cell_value
}

pub fn get_cell_value_mut(&mut self) -> &mut CellValue {
pub(crate) fn get_cell_value_mut(&mut self) -> &mut CellValue {
&mut self.cell_value
}

pub fn set_cell_value(&mut self, value: CellValue) -> &mut Self {
self.cell_value = value;
self
}

pub fn get_style(&self) -> &Style {
&self.style
}
Expand Down
2 changes: 1 addition & 1 deletion src/structs/cell_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::borrow::Cow;
use structs::CellRawValue;

#[derive(Clone, Default, Debug, PartialEq, PartialOrd)]
pub struct CellValue {
pub(crate) struct CellValue {
pub(crate) raw_value: CellRawValue,
pub(crate) formula: Option<String>,
pub(crate) formula_attributes: Vec<(String, String)>,
Expand Down
17 changes: 0 additions & 17 deletions src/structs/spreadsheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,23 +177,6 @@ impl Spreadsheet {
}
}

/// Gets the cell value by specifying an address.
/// # Arguments
/// * `address` - address. ex) "Sheet1!A1:C5"
/// # Return value
/// *`Vec<&CellValue>` - CellValue List.
/// # Examples
/// ```
/// let mut book = umya_spreadsheet::new_file();
/// let mut cell_value_List = book.get_cell_value_by_address("Sheet1!A1:C5");
/// ```
pub fn get_cell_value_by_address(&self, address: &str) -> Vec<&CellValue> {
let (sheet_name, range) = split_address(address);
self.get_sheet_by_name(&sheet_name)
.unwrap()
.get_cell_value_by_range(&range)
}

/// (This method is crate only.)
/// Gets the cell value by specifying an Address Object.
/// # Arguments
Expand Down
80 changes: 1 addition & 79 deletions src/structs/worksheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,84 +315,6 @@ impl Worksheet {
self
}

/// Get cell value.
/// # Arguments
/// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)`
/// # Return value
/// * `&CellValue` - CellValue.
/// # Examples
/// ```
/// let book = umya_spreadsheet::new_file();
/// let worksheet = book.get_sheet(&0).unwrap();
/// let cell_value = worksheet.get_cell_value("A1");
/// // or pass in a tuple `(col, row)`, both col and row starting at `1`
/// let cell_value = worksheet.get_cell_value((1, 1));
/// ```
pub fn get_cell_value<T>(&self, coordinate: T) -> &CellValue
where
T: Into<CellCoordinates>,
{
let CellCoordinates { col, row } = coordinate.into();
self.cell_collection.get_cell_value(&col, &row)
}

/// Gets the cell value by specifying the column number and row number.
/// # Arguments
/// * `col` - Specify the column number. (first column number is 1)
/// * `row` - Specify the row number. (first row number is 1)
/// # Return value
/// * `&CellValue` - CellValue.
/// # Examples
/// ```
/// let book = umya_spreadsheet::new_file();
/// let worksheet = book.get_sheet(&0).unwrap();
/// let cell_value = worksheet.get_style_by_column_and_row(&1, &1); // get cell from A1.
/// ```
#[deprecated(note = "use `get_cell_value` instead")]
pub fn get_cell_value_by_column_and_row(&self, col: &u32, row: &u32) -> &CellValue {
self.cell_collection.get_cell_value(col, row)
}

/// Get cell value with mutable.
/// # Arguments
/// * `coordinate` - Specify the coordinates. ex) `"A1"` or `(1, 1)`
/// # Return value
/// * `&mut CellValue` - CellValue with mutable.
/// # Examples
/// ```
/// let mut book = umya_spreadsheet::new_file();
/// let mut worksheet = book.get_sheet_mut(&0).unwrap();
/// let cell_value = worksheet.get_cell_value_mut("A1");
/// // or pass in a tuple `(col, row)`, both col and row starting at `1`
/// let cell_value = worksheet.get_cell_value_mut((1, 1));
/// ```
pub fn get_cell_value_mut<T>(&mut self, coordinate: T) -> &mut CellValue
where
T: Into<CellCoordinates>,
{
let CellCoordinates { col, row } = coordinate.into();
self.get_row_dimension_mut(&row);
self.cell_collection.get_mut(&col, &row).get_cell_value_mut()
}

/// Gets the cell value with mutable by specifying the column number and row number.
/// # Arguments
/// * `col` - Specify the column number. (first column number is 1)
/// * `row` - Specify the row number. (first row number is 1)
/// # Return value
/// *`&mut CellValue` - CellValue with mutable.
/// # Examples
/// ```
/// let mut book = umya_spreadsheet::new_file();
/// let mut worksheet = book.get_sheet_mut(&0).unwrap();
/// let cell_value = worksheet.get_cell_value_by_column_and_row_mut(&1, &1); // get cell_value from A1.
/// ```
#[deprecated(note = "use `get_cell_value_mut` instead")]
pub fn get_cell_value_by_column_and_row_mut(&mut self, col: &u32, row: &u32) -> &mut CellValue {
self.get_row_dimension_mut(&row);
self.cell_collection.get_mut(col, row).get_cell_value_mut()
}

/// Gets the cell value by specifying an range.
/// # Arguments
/// * `range` - range. ex) "A1:C5"
Expand All @@ -404,7 +326,7 @@ impl Worksheet {
/// let mut worksheet = book.get_sheet_mut(&0).unwrap();
/// let mut cell_value_List = worksheet.get_cell_value_by_range("A1:C5");
/// ```
pub fn get_cell_value_by_range(&self, range: &str) -> Vec<&CellValue> {
pub(crate) fn get_cell_value_by_range(&self, range: &str) -> Vec<&CellValue> {
self.cell_collection.get_cell_value_by_range(range)
}

Expand Down