BsonDocumentWriter To a file?

Hi.
i have a couple of question about BsonDocument… i need to write a data to a bson document without the usage of MongoDB is that possible?

i had a look into BsonDocumentWriter that should be fine to write a document, but i can’t figure out how to write it to a file?

Hello @Mirko_Rossetti, welcome to the MongoDB Community forum!

i need to write a data to a bson document without the usage of MongoDB is that possible?

Do you want to write the MongoDB document data to a file as JSON documents? In such a case use the mongoexport command-line tool.

hello @Prasad_Saya , thank’s you for your reply.

well what i actually have is a Excel sheets, and i want to write it’s data to a BSON file, let me explain why.
the data will be used to populate some structure on the final project ( i’m working on a conversion tool ) since the final project that would use that bson file to read data will do it runtime, i need something faster than json and someone suggest me to use bson instead, so i’m trying to figure out how i actually should use it, because i really don’t need the driver i need only to serialize my data into bson file then read it out on the project that are going to use that file ( right now i’m using C# but i’ll also use C++)

Hi @Mirko_Rossetti, the Excel data is already in some kind of binary format. There are quite a few tools (some open source) to read the data and manipulate it in a programming language and write back to Excel sheets. For example, Apache POI is one such library (its a Java library) and NPOI is the .NET version. I am sure there are some such libraries or tools to read form Excel in C# or C++ (a quick Google search can do that, for example “bson data reader”).

hi @Prasad_Saya yes, i already did that part, i have successfully stored my file into a datatable or CSV, but instead of it i want to write my data into a BSON file format, right now i’m trying to use BsonDocumentWriter to write the data to the bsondocument, but how i shouldsave to a file after that? since all the example that i found out is under the driver i’m wondering in how to use it properly.