Reading and writing workbooks.
WHEN TO USE A LIBRARY
When you must read or produce actual spreadsheet files rather than plain text.
WHAT TO PREFER WHERE POSSIBLE
CSV, which is simpler and more reliable.
WHAT LIBRARIES PROVIDE
Reading cell values Writing new workbooks Handling several sheets Basic formatting
WHAT TO BE CAREFUL WITH
Formulas, which may be stored rather than evaluated Dates, which are stored as numbers Merged cells Hidden rows and sheets
THE DATE POINT
Dates read from a workbook frequently arrive as numbers and need converting.
THE FORMULA POINT
Reading a file may give you the formula, not the result, depending on how it was saved.
Establish which before relying on values.
WHAT TO VALIDATE
Row counts That the columns are where you expect That headers match
WHY
Workbooks are edited by people, and structure changes without notice.
WHAT TO DO ABOUT THAT
Locate columns by header name rather than position.
WHAT TO PRODUCE FOR OTHERS
Clean output with a header row and no merged cells.