Still can not deserialize excel sheet
` fn read_excel(file_path: &str) -> Result<(), Box<dyn std::error::Error>> { let mut wb = open_workbook::<Xlsx<_>, _>(file_path)?;
#[derive(Debug, Deserialize)]
struct Row {
#[serde(rename = "Quantity")]
quantity: u32,
#[serde(rename = "Product Name")]
product_name: String,
#[serde(rename = "Condition")]
condition: String,
#[serde(rename = "Final condition")]
final_condition: String,
#[serde(rename = "Serial Tracking")]
serial_tracking: String,
#[serde(rename = "MFG Serial")]
mfg_serial: String,
#[serde(rename = "Serial")]
serial: Option<String>,
#[serde(rename = "Cost")]
cost: u32,
#[serde(rename = "Price")]
price: Option<String>,
#[serde(rename = "Location")]
location: String,
#[serde(rename = "Warranty")]
warranty: Option<String>,
#[serde(rename = "Color")]
color: Option<String>,
#[serde(rename = "Type")]
the_type: Option<String>,
#[serde(rename = "Form Factor")]
form_factor: Option<String>,
#[serde(rename = "Category")]
category: String,
#[serde(rename = "Brand")]
brand: String,
#[serde(rename = "Series")]
series: Option<String>,
#[serde(rename = "Model")]
model: String,
#[serde(rename = "Model No")]
model_no: Option<String>,
#[serde(rename = "CPU")]
cpu: String,
#[serde(rename = "GPU")]
gpu: Option<String>,
#[serde(rename = "TotalRam")]
total_ram: String,
#[serde(rename = "TotalStorage")]
total_storage: Option<String>,
#[serde(rename = "Storage Config")]
storage_config: Option<String>,
#[serde(rename = "Screen Size")]
screen_size: Option<String>,
#[serde(rename = "Screen Resolution")]
screen_resolution: Option<String>,
#[serde(rename = "Resolution Code")]
resolution_code: Option<String>,
#[serde(rename = "Refresh Rate")]
refresh_rate: Option<String>,
#[serde(rename = "Screen Panel")]
screen_panel: Option<String>,
#[serde(rename = "Touchscreen")]
touch_screen: Option<String>,
#[serde(rename = "Keyboard")]
keyboard: Option<String>,
#[serde(rename = "Cam")]
cam: Option<String>,
#[serde(rename = "Battery")]
battery: String,
#[serde(rename = "Hinge")]
hinge: Option<String>,
#[serde(rename = "Mouse")]
mouse: Option<String>,
#[serde(rename = "Audit Result")]
audit_result: Option<String>,
#[serde(rename = "Issues")]
issues: Option<String>,
#[serde(rename = "Notes")]
notes: String,
#[serde(rename = "SpacePro ID")]
spacepro_id: Option<String>,
#[serde(rename = "Images")]
image: Option<String>,
}
let sh1 = wb.worksheet_range("Sheet1")?;
let deser1 = sh1.deserialize()?;
let mut rows1: Vec<Row> = Vec::new();
for row in deser1 {
rows1.push(row?);
}
println!("sheet 1: {rows1:?}");
Ok(())
} `
I have this error Error processing Excel: missing field Quantity``
Although I have an Excel sheet with columns the same as the struct above
try to use Option<u32> ?
I suspect some cell are not integers?
I get the same error if i changed the order of struct props . For example if the first prop is ( brand ) i got the error (Error processing Excel: missing field Brand ) So it is not about the column itself.
Any reason
have you tried to put Option?? Without the source file it is hard to guess.
@HosMercury Could you please attach a sample file in order to debug this. It can contain sample (non-proprietary) data but it should be in the format that you expect and with the same headers.
Without a sample file it isn't possible to say what the issue is and this question will be closed.
Closing due to a lack of a reproducible file. Will reopen/reinvestigate if a file is provided.