To help convert a txt file into a xlsx file in a folder

My code is not working

write.xlsx2(df,"Total.xlsx", Col.names=TRUE, row.names=TRUE)
Error in write.xlsx2(df, "Total.xlsx", Col.names = TRUE, row.names = TRUE) :
could not find function "write.xlsx2"

write.csv2(df, "total.xlsx", col.names= TRUE, row.names= TRUE)
Warning message:
In write.csv2(df, "total.xlsx", col.names = TRUE, row.names = TRUE) :
attempt to set 'col.names' ignored

Perhaps you should try:
Write.xlsx(df,"Total.xlsx", Col.names=TRUE, row.names=TRUE)

Hope this helps

I think you have a W when you want a w

write.xlsx(df,"Total.xlsx", Col.names=TRUE, row.names=TRUE)
1 Like

Is the package xlsx installed?

I do get a truncated portion of the file as result. Can't it be possible to convert a .txt file directly into *.xlsx file?

Yes indeed. Sorry it should have been write.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.