private void SetConnection(SpreadsheetDocument document) { var connectionPart = document.WorkbookPart.AddNewPart <ConnectionsPart>(NewId()); var connections = new Connections(); var connection = new Connection { Id = ConnectionId, Name = ConnectionName, Type = 4U, RefreshedVersion = 0, Background = true }; connection.AppendChild(new WebQueryProperties { XmlSource = true, SourceData = true, ParsePreTag = true, Consecutive = true, Url = "C:\\file.xml", HtmlTables = true }); connections.AppendChild(connection); connectionPart.Connections = connections; }