это простой Вставить в файл XML с помощью C#
{ метод Invoke первый ..............
public void InvokeKey()
{
DSXml.ReadXml(@"c:\users\general\documents\visual studio 2010\Projects\xml_practice\xml_practice\todolist.xml");
DataColumn[] ID = new DataColumn[1];
ID[0] = DSXml.Tables[0].Columns[0];
DSXml.Tables[0].PrimaryKey = ID;
}
DataSet DsXml = новый DataSet(); DataRow DrXML;
string Date = Convert.ToString(System.DateTime.Now.ToString("d"));
string Time = Convert.ToString(System.DateTime.Now.ToString("hh:mm:ss"));
int ID;
InvokeKey();
DRXML = DSXml.Tables[0].Rows.Find(ID);
DsXml.WriteXml(@"path");
DrXML = DsXml.Tables[0].NewRow();
DrXML[0] = ID;
DrXML[0] = ID;
DrXML[0] = ID;
DrXML[0] = ID;
DrXML[0] = ID;
DrXML[0] = ID;
DsXml.Tables[0].Rows.Add(DrXML);
DsXml.WriteXml(@"path");
dt = REport.LoadSubjects();
Excel.Application xlApp = new Excel.Application(); // open app
xlApp.Visible = true;
Excel.Workbook xlWorkBook = xlApp.Workbooks.Add(1); //open workbook
Excel.Worksheet xlSheet = (Excel.Worksheet)xlWorkBook.Worksheets[1]; //open worksheet
xlSheet.Cells.Rows.Columns.AutoFit();
string strTempVariable = dt.Rows[0][0].ToString(); //temporary variable
xlSheet.Cells[4, 1] = dt.Rows[0][0].ToString();
xlSheet.Cells[1, 1] = "Employees group header";
for (int count = 0; count < dt.Columns.Count;count++)
{
xlSheet.Cells[3, count+1] = dt.Columns[count].ColumnName;// prints column names
}
int group=0;
int total=0;
int intRow = 5;//manages xlsheet
for (int counter = 0; counter < dt.Rows.Count;counter++)
{
if (strTempVariable == dt.Rows[counter]["City"].ToString())
{
xlSheet.Cells[intRow, 2] = dt.Rows[counter][1];
xlSheet.Cells[intRow, 3] = dt.Rows[counter][2];
xlSheet.Cells[intRow, 4] = dt.Rows[counter][3];
xlSheet.Cells[intRow, 5] = dt.Rows[counter][4];
group++;
total++;
intRow++;
}
else
{
xlSheet.Cells[intRow, 4] = "group name " + strTempVariable + " " + group.ToString();
strTempVariable = dt.Rows[counter][0].ToString();
intRow++;
xlSheet.Cells[intRow, 1] = strTempVariable;
intRow++;
counter--;
group = 0;
}
}
intRow++;
xlSheet.Cells[intRow, 4] = "group name " + strTempVariable + " "+group.ToString();
intRow++;
xlSheet.Cells[intRow, 4] = "GrandTotal " + " "+total.ToString();
xlWorkBook.Close(true, "GROUP REPORT", 0);//The name of the worksheet
xlApp.Quit();
// return "Report Successfully";
}
общественная строка ReportTimeTable() {
DataTier.clsDataAccess Data = new DataTier.clsDataAccess();
int intCount = 0;
int intCount2 = 5;
Data.sqlcon.Close();
Data.sqlcon.Open();
Data.sqlAdpter = new SqlDataAdapter("SELECT * FROM USERS ORDER BY password",Data.sqlcon);
DataTable ReportDt = new DataTable("Report");
Data.sqlAdpter.Fill(ReportDt);
Data.sqlcon.Close();
string strMsg = "";
Excel.Application xlApp = new Excel.Application();
xlApp.Visible = true;
Excel.Workbook xlWorkbook = xlApp.Workbooks.Add(1);
Excel.Worksheet xlWorksheet = (Excel.Worksheet)xlWorkbook.Sheets[1];
// Setting cell values
((Excel.Range)xlWorksheet.Cells[1, "A"]).Value2 = "Report - USERS "; //main heading
((Excel.Range)xlWorksheet.Cells[3, "A"]).Value2 = "USERNAME"; //field headings
((Excel.Range)xlWorksheet.Cells[3, "B"]).Value2 = "PASSWORD";
// ((Excel.Range)xlWorksheet.Cells[3, "C"]).Value2 = "MARK";
for (intCount = 0; intCount < ReportDt.Rows.Count; intCount++)
{
xlWorksheet.Cells[intCount2, "A"] = ReportDt.Rows[intCount][0];
xlWorksheet.Cells[intCount2, "B"] = ReportDt.Rows[intCount][1];
// xlWorksheet.Cells[intCount2, "C"] = ReportDt.Rows[intCount][2];
intCount2++;
}
xlWorksheet.Cells.Columns.AutoFit();
strMsg = "report successful";
return strMsg;
XML является текст - он не может "запустить" на что-нибудь. Программа может читать XML, интерпретировать его и делать что-то с информацией. – Oded
вы можете открыть xml-файл с помощью блокнота. Или еще лучше попробуйте [Notepad ++] (http://notepad-plus-plus.org/). Приложение по умолчанию для открытия файла для данного расширения (.xml в этом случае) может быть изменено на приложение по вашему выбору. –
Должен быть помечен как «путаница идей».См. @Oded: XML - это данные, вы не запускаете данные. Обычные текстовые данные, кстати, поэтому не нужен специальный редактор (но очень полезный текстовый редактор очень полезен - +1 для Notepad ++). – delnan