15 unstable releases (3 breaking)

0.4.6 Nov 2, 2024
0.4.5 Jun 19, 2024
0.4.4 Apr 29, 2024
0.3.9 Apr 7, 2024
0.1.0 Jan 30, 2024

#515 in Parser implementations

Download history 6/week @ 2024-08-05 28/week @ 2024-08-19 9/week @ 2024-08-26 9/week @ 2024-09-16 63/week @ 2024-09-23 14/week @ 2024-09-30 6/week @ 2024-10-07 1/week @ 2024-10-14 113/week @ 2024-10-28 43/week @ 2024-11-04 10/week @ 2024-11-11 8/week @ 2024-11-18

174 downloads per month

MIT license

380KB
8K SLoC

edit-xlsx

github crates.io docs.rs build status

Welcome to Edit-xlsx, your quick and easy-to-use Rust library for Excel file editing. Whether you're a developer working on a project that involves manipulating Excel files or a business user streamlining data workflows, Edit-xlsx is designed to make Excel editing a breeze.

Features

  • Formula Editing: Easily manipulate and customize formulas in Excel sheets.
  • Cell Text Editing: Edit the content of individual cells, including inserting, modifying, or deleting text.
  • Background Setting: Set and adjust background colors for cells or ranges.
  • Image Insertion: Seamlessly insert images into your Excel files.
  • Format Setting: Apply various formatting options to cells, such as font styles, sizes, and text alignments.
  • Cell Merging: Merge cells to create visually appealing layouts.
  • Worksheet Editing: Edit and manage worksheets with ease.
  • Pane Manipulation: Control and customize panes for a better viewing experience.

Getting Started

Getting started with Edit-xlsx is a straightforward process. Add the library to your Rust project, and you can instantly enjoy the convenience of simplified Excel editing.

Installation

To use Edit-xlsx in your Rust project, add the following to your Cargo.toml file:

[dependencies]
edit-xlsx = "0.4.6"

Notice

If you encounter any issues or have questions while using Edit-xlsx, please don't hesitate to reach out. Feel free to create an issue on our issue tracker. Your feedback is valuable, and we are here to assist you!

Usage

A simple example of usage is shown below, and you can see more examples in the example directory

use edit_xlsx::{Format, FormatAlignType, FormatBorderType, FormatColor, Workbook, WorkbookResult, WorkSheet, Write};

fn main() -> WorkbookResult<()> {
    // Create a new workbook
    let mut workbook = Workbook::new();
    let worksheet = workbook.get_worksheet(1)?;
    // write some text
    WorkSheet::write(worksheet, "A1", "Hello")?;
    worksheet.write("B1", "World")?;
    worksheet.write("C1", "Rust")?;
    // Adjust font size
    let big = Format::default().set_size(32);
    worksheet.write_with_format("B1", "big text", &big)?;
    // Change font color
    let red = Format::default().set_color(FormatColor::RGB(255, 119, 119));
    worksheet.write_with_format("C1", "red text", &red)?;
    // Change the font style
    let bold = red.set_bold();
    worksheet.write_with_format("D1", "red bold text", &bold)?;
    // Change font
    let font = Format::default().set_font("华文行楷");
    worksheet.write_with_format("E1", "你好", &font)?;
    // adjust the text align
    let left_top = Format::default().set_align(FormatAlignType::Left).set_align(FormatAlignType::Top);
    worksheet.write_with_format("A2", "left top", &left_top)?;
    // add borders
    let thin_border = Format::default().set_border(FormatBorderType::Thin);
    worksheet.write_with_format("B2", "bordered text", &thin_border)?;
    // add background
    let red_background = Format::default().set_background_color(FormatColor::RGB(255, 119, 119));
    worksheet.write_with_format("C2", "red", &red_background)?;
    // add a number
    worksheet.write("D2", std::f64::consts::PI)?;
    // add a new worksheet and set a tab color
    let worksheet = workbook.add_worksheet_by_name("Other examples")?;
    worksheet.set_tab_color(&FormatColor::RGB(255, 153, 0)); // Orange
    // Set a background.
    worksheet.set_background("examples/pics/ferris.png")?;
    // Create a format to use in the merged range.
    let merge_format = Format::default()
        .set_bold()
        .set_border(FormatBorderType::Double)
        .set_align(FormatAlignType::Center)
        .set_align(FormatAlignType::VerticalCenter)
        .set_background_color(FormatColor::RGB(255, 255, 0));
    // Merge cells.
    worksheet.merge_range_with_format("A1:C3", "Merged Range", &merge_format)?;
    // Add an image
    worksheet.insert_image("A4:C10", &"./examples/pics/rust.png")?;
    workbook.save_as("examples/hello_world.xlsx")?;
    Ok(())
}

License

This library is licensed under the MIT License.

Feel free to reach out if you have any questions or encounter any issues. Happy coding with Edit-xlsx!

Dependencies

~7–15MB
~182K SLoC