consider the following list of Cell[]'s:
cells = {
Cell[
"foo=\"string1\";(*comment*)bar=\"string2\";"
, "Input"
]
,Cell[
"foo=\"string1\";(*comment*)bar=\"string2\";"
, "Input"]
};
nb = Notebook[{cells}];
SystemOpen@Export[$HomeDirectory <> "/notebook.nb", nb]
Using the Notebook
function, I can create and export a notebook, but there is no syntax highlighting.