【发布时间】:2023-01-12 04:35:29
【问题描述】:
我想用 Rust 链接我的 excel 数据库。 我写了下面的代码,但发生了一些错误。
use calamine::{open_workbook,Render,xlsx};//
fn main(){
let xl_book_path="Your Excle Book Path.xlsx";
let met wb: Xlsx<_> = opne_workbook(Xl_book_path).expect("cannot open xl book");
}
error[E0432]: unresolved import `calamine`
--> Aut.rs:1:5
| 1 | use calamine::{open_workbook,Render,xlsx};
| ^^^^^^^^ maybe a missing crate `calamine`?
| = help: consider adding `extern crate calamine` to use the `calamine` crate
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0432`.
我认为原因是 Cargo.toml 中缺少calamine,
所以我在 Cargo.toml 中添加了炉甘石。
[dependencies] calamine = "0.18.0"
但错误仍然出现。 我该如何解决这个问题?
【问题讨论】:
-
你不是故意在你的代码中添加
extern crate calamine吗? -
谢谢回复。我不知道“extern crate calamine”,所以我用 Cargo.toml 添加了炉甘石代码(第 8,9 行)。你的意思是需要添加代码?
-
这取决于您在 cargo.toml 中设置的 Rust 版本。里面有“edition = ...”行吗?
-
您应该按原样发布您的 cargo.toml、main.rs 的重要部分(不是手工重写——请注意您在上面的“opne_workbook”中有错字),以及您用来尝试构建/运行程序。这将有助于理解问题。
-
你是用 Cargo 搭建,还是直接调用
rustc?
标签: rust