use rust_xlsxwriter::{Color, Format, FormatUnderline, Workbook, XlsxError};
fn main() -> Result<(), XlsxError> {
let mut workbook = Workbook::new();
let link_format = Format::new()
.set_font_color(Color::Red)
.set_underline(FormatUnderline::Single);
let worksheet1 = workbook.add_worksheet();
worksheet1.set_column_width(0, 26)?;
worksheet1.write_url(0, 0, "https://www.rust-lang.org")?;
worksheet1.write_url_with_text(1, 0, "https://www.rust-lang.org", "Learn Rust")?;
worksheet1.write_url_with_format(2, 0, "https://www.rust-lang.org", &link_format)?;
worksheet1.write_url(4, 0, "internal:Sheet1!A1")?;
worksheet1.write_url(5, 0, "internal:Sheet2!C4")?;
worksheet1.write_url(7, 0, r"file:///C:\Temp\Book1.xlsx")?;
worksheet1.write_url(8, 0, r"file:///C:\Temp\Book1.xlsx#Sheet1!C4")?;
let worksheet2 = workbook.add_worksheet();
worksheet2.write_string(3, 2, "Here I am")?;
worksheet2.write_url_with_text(4, 2, "internal:Sheet1!A6", "Go back")?;
workbook.save("hyperlinks.xlsx")?;
Ok(())
}