Comments (7)
The wrapped libxlsxwriter library doesn't have a function/method for writing a url and specifying an alternative string like the Perl/Python versions. Instead, the suggested workaround is to write the URL and then overwrite the cell with an alternative string with the same cell format.
Here is an xlsxwriter.rs
example:
use xlsxwriter::{format::*, Workbook};
fn main() -> Result<(), xlsxwriter::XlsxError> {
let workbook = Workbook::new("gh54.xlsx")?;
let mut worksheet = workbook.add_worksheet(None)?;
// Create a url format.
let mut url_format = Format::new();
url_format.set_font_color(FormatColor::Blue);
url_format.set_underline(FormatUnderline::Single);
let image_url = "https://docs.rs/-/rustdoc.static/rust-logo-151179464ae7ed46.svg";
// Write a url.
worksheet.write_url(0, 0, image_url, Some(&url_format))?;
// Overwrite the displayed URL string with another string. Note, we need to
// specify the format for the string to match the hyperlink.
worksheet.write_string(0, 0, "Photo 1", Some(&url_format))?;
workbook.close()
}
Output:
Sample file: gh54.xlsx
from xlsxwriter-rs.
I was under an impression that the way they do it gives you an ability to insert multiple links via comma, like "Photo 1, Photo2, Photo3" all in single cell, each going to its own URL.
Unfortunately, that isn't possible in Excel. It only allows one URL per cell.
from xlsxwriter-rs.
Do you mean you want to link to some image within the file or to some image at an external URL?
from xlsxwriter-rs.
External url opened in browser, basically a web page.
from xlsxwriter-rs.
That's a clever hack, thank you! Created an upstream issue at jmcnamara/libxlsxwriter#416 too
from xlsxwriter-rs.
That's a clever hack, thank you! Created an upstream issue at jmcnamara/libxlsxwriter#416 too
That isn't really a hack. It is the documented way of doing it in libxlsxwriter. It is also more or less what Excel does (it stores a link for the cell but also adds an additional text, or number, or formula, for the cell).
If it works for your use case you should close this issue.
from xlsxwriter-rs.
Oh, I see. I didn't check if it's possible in JS lib, but I was under an impression that the way they do it gives you an ability to insert multiple links via comma, like "Photo 1, Photo2, Photo3" all in single cell, each going to its own URL. I don't need it for now, can open a new issue later if needed.
from xlsxwriter-rs.
Related Issues (20)
- `freeze_panes` does not appear to work HOT 5
- Debug trait for format enums HOT 1
- Non-ASCII path xlsx file creation failed (Windows) HOT 2
- Data validation booleans are inverted HOT 1
- v0.4.0 fails to compile, possibly on arm-based (aarch64) mac
- Invalid xlsx files generated with some locales
- [security] write_string panics upon null byte injection attempts HOT 1
- Compile failed of v0.5.0 on ARM Mac Osx HOT 1
- would it make more sense to make (row, col) a tuple in all function signatures
- call sheet.data_validation_cell crash HOT 3
- Make DataValidationType a data-bound enum HOT 3
- Not able to export the huge data (more than 32767 characters) HOT 2
- Change ErrorAlert and InputMessage to builder pattern
- New release of libxlsxwriter-sys? HOT 2
- Will this repository get a long term support? HOT 2
- Compilation failure with outdated `libxlsxwriter_sys` HOT 2
- Color fine alpha management HOT 1
- Readme example uses deprecated api
- Error building wasm32-wasi target
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xlsxwriter-rs.