XML file as an Excel file

I have several reports that I run against my database, which ultimately should go to end users in the form of Excel spreadsheets.

At first I created text reports, but the steps to convert the text to a spreadsheet were a bit cumbersome. There were too many steps to import text into a spreadsheet, and multi-line text lines were imported as separate lines in Excel (which was incorrect).

I am currently creating simple XML saving a file with the extension ".xls". This works better, but there is still a problem with Excel asking the user with an XML import dialog every time they open the file, and then save the new file if they add notes or change the layout in the file (which they will almost certainly do )

Example file "xls":

<?xml version="1.0" standalone="yes"?>             
<report_rows>                                      
  <row>                                            
    <NAME>Test Data</NAME> 
    <COUNT>345</COUNT>                 
  </row>
  <!-- many more row elements... -->
</report_rows>

Is there a way to add markup to a file in order to hint at Excel how it should import and process the file? Ideally, the end user should be able to open and save the file, like any spreadsheet that they create directly from Excel.

Is it possible?

UPDATE:

Here we launch Office 2003.

UPDATE:

XML is created from sqlplus script, there is no possibility to use C # /. NET here.

+3
2

Excel 2003 2007 XML SpreadSheet (XMLSS), . . , XML, , , . Excel XMLSS.

+1

, , , XML Excel - Visual Basic (VBA). VBA, , http://www.anthony-vba.kefra.com/index.htm.

'Create an instance of the FileSystemObject
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Get the folder object
 Set objFolder = objFSO.GetFolder("C:\Sem-o_Archive\XML")

'loops through each file in the directory and prints their names and path
For Each objFile In objFolder.Files
cutting = Left(objFile.name, 15)
Workbooks.Add
ActiveWorkbook.XmlImport URL:="C:\path\to\files\" & objFile.name,      ImportMap:=Nothing, _
                     Overwrite:=True, Destination:=range("$A$1")
ActiveWorkbook.SaveAs "C:\path\to\save\location" & cutting & "xls"
ActiveWorkbook.Close True
Next objFile

xml , , xml .

, .

0

Source: https://habr.com/ru/post/1740219/


All Articles