我怎样才能保存的格式,而从excel数据导出到Evernote

我在Excel中有以下代码,它将每行和每列的数据导入到每行的单个注释中。

但是它并不像在Excel中那样格式化数据,而是直接打印单元格内容。

这是它现在的样子,当我impor .enex文件

导入数据的屏幕截图 这是它在excel中的样子。

在这里输入图像说明

Option Explicit Sub OutputNotesXML() Dim iRow As Long Close #1 With ActiveSheet 'For iRow = 2 To 2 Open ThisWorkbook.Path & "\evernote-import.enex" For Output As #1 Print #1, "<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>" Print #1, "<!DOCTYPE en-export SYSTEM " & Chr(34) & "http://xml.evernote.com/pub/evernote-export.dtd" & Chr(34) & ">" Print #1, "<en-export export-date=" & Chr(34) & "20120202T073208Z" & Chr(34) & " application=" & Chr(34) & "Evernote/Windows" & Chr(34) & " version=" & Chr(34) & "4.x" & Chr(34) & ">" For iRow = 2 To .Cells(.Rows.Count, "A").End(xlUp).Row Print #1, "<note><title>" Print #1, .Cells(iRow, "A").Value 'Title Print #1, "</title><content><![CDATA[<?xml version=" & Chr(34) & "1.0" & Chr(34) & " encoding=" & Chr(34) & "UTF-8" & Chr(34) & "?>" Print #1, "<!DOCTYPE en-note SYSTEM " & Chr(34) & "http://xml.evernote.com/pub/enml2.dtd" & Chr(34) & ">" Print #1, "<en-note style=" & Chr(34) & "word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" & Chr(34) & ">" Print #1, CBr(.Cells(iRow, "B").Value) & vbNewLine 'Note Print #1, CBr(.Cells(iRow, "C").Value) & vbNewLine 'Note Print #1, CBr(.Cells(iRow, "D").Value) & vbNewLine 'Note Print #1, CBr(.Cells(iRow, "E").Value) 'Note Print #1, CBr(.Cells(iRow, "F").Value) 'Note Print #1, CBr(.Cells(iRow, "G").Value) 'Note Print #1, CBr(.Cells(iRow, "H").Value) 'Note Print #1, CBr(.Cells(iRow, "I").Value) 'Note Print #1, CBr(.Cells(iRow, "J").Value) 'Note Print #1, CBr(.Cells(iRow, "K").Value) 'Note Print #1, CBr(.Cells(iRow, "L").Value) 'Note Print #1, CBr(.Cells(iRow, "M").Value) 'Note Print #1, CBr(.Cells(iRow, "N").Value) 'Note Print #1, CBr(.Cells(iRow, "O").Value) 'Note Print #1, CBr(.Cells(iRow, "P").Value) 'Note Print #1, CBr(.Cells(iRow, "Q").Value) 'Note Print #1, CBr(.Cells(iRow, "R").Value) 'Note Print #1, CBr(.Cells(iRow, "S").Value) 'Note Print #1, CBr(.Cells(iRow, "T").Value) 'Note Print #1, CBr(.Cells(iRow, "U").Value) 'Note Print #1, CBr(.Cells(iRow, "V").Value) 'Note Print #1, CBr(.Cells(iRow, "W").Value) 'Note Print #1, CBr(.Cells(iRow, "X").Value) 'Note Print #1, CBr(.Cells(iRow, "Y").Value) 'Note Print #1, CBr(.Cells(iRow, "Z").Value) 'Note Print #1, CBr(.Cells(iRow, "AA").Value) 'Note Print #1, CBr(.Cells(iRow, "AB").Value) 'Note Print #1, CBr(.Cells(iRow, "AC").Value) 'Note Print #1, "</en-note>]]></content><created>" 'Print #1, .Cells(iRow, "D").Text 'Created Date in Evernote Time Format... 'To get the evernote time, first convert your time to Zulu/UTC time. 'Put this formula in Column D: =C2+TIME(6,0,0) where 6 is the hours UTC is ahead of you. 'Then right click on your date column, select format, then select custom. Use this custom code: yyyymmddThhmmssZ Print #1, "</created><updated>201206025T000001Z</updated></note>" Next iRow Print #1, "</en-export>" Close #1 End With End Sub Function CBr(val) As String 'parse hard breaks into to HTML breaks CBr = Replace(val, Chr(13), "") CBr = Replace(CBr, "&", "&amp;") End Function 'I modified this code from Marty Zigman's post here: http://blog.prolecto.com/2012/01/31/importing-excel-data-into-evernote-without-a-premium-account/ 

Evernote笔记的内容在ENML中 ,它是xHTML的超集。 您将看到允许的元素列表包含<table><tr><td>等标签,因此您可以使用这些元素为笔记内容构build一个html表格。

另一种解决scheme是通过CSS来完成。 需要注意的是,CSS必须在每个元素的style属性中使用,作为内联样式。 请注意,标签也被支持。

我build议你首先手动在Evernote中创build一个看起来像你想要的注释,然后将该注释导出到ENEX。 然后您可以检查ENEX文件,看看需要如何格式化。

我注意到的一个关键问题是,Evernote应用程序本身广泛使用HTML <div>标签,而不是<p><br>来实现行之间没有空格的行。

如果您希望EN注释将数据显示为表格(如Excel),则需要在输出中使用HTML <table>标记。