Home » .Net Framework

Cannot view XML input using XSL style sheet.


whenever I open a xml file, 

It gave me this:

The XML page cannot be displayed

Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.

Access is denied. Error processing resource ....



I tried reinstalling my framework, I downlaoded messagelof.xsl,

But nothing works.


Any ideas?


I have these versions:










1 Answer Found


Answer 1

Please be more specific, telling "whenever I open a xml file" does not tell us at all which application you use to open an XML file. This forum is about XML in the .NET framework and about XML Tools in Visual Studio so you are in the right forum if you use Visual Studio to open an XML file or if you programmatically use the .NET framework XML APIs to parse an XML file.

I suspect you use a browser like Internet Explorer to open an XML file. The error message "Access is denied" suggests that the XML document references another resource on a different location that the one the XML is opened from. So show us the start of the XML file with stuff like <?xml-stylesheet?> and/or <!DOCTYPE>. And tell us whether you load the XML document over HTTP from a web server or from the local file system.



Hello I am using an application to transform XML files against an XML style sheet. My problem is how do I modify the style sheet so when the XML file gets transformed it will have the option to include an Image Table for RTL languages. Also I need to know how to replace image names in the said XML through the style sheet too. What should I be adding to the style sheet to achieve this? Thanks for any help


I have a userform where the user inputs information into textboxes, and then hits a command button, which sends the information from the various textboxes to different columns in an Excel sheet.  The code works fine, except for a textbox where the user will input a number.  for that box, the textbox sends the number to the sheet as text, not as a number.

I have tried various ways to fix this, and have put my "solutions" in different places in the code, but nothing has worked so far.  Should I be using something besides a textbox?  Is there a way to have the text be sent as a number?  After the userform sends the number to Excel as text, Excel immediately recognizes the problem and puts up a little exclamation point with a notice that a number has been entered as text and gives the option to covert it, but of course I'd rather have the number entered as a number in the first place.  If anyone has any ideas, I'd appreciate it.  Thanks!

I am running Vista (Excel 2007).


This question is similar to a previous question I asked on this board.  There, I had a userform textbox where I needed Excel to interpret user input as a number instead of text.

The only difference now is that I need Excel to interpret the input from a textbox as a date rather than a number.  It's the same situation: the user inputs a date into a textbox and then a command button sends that information to a cell.

The solution to the last question was:

If IsNumeric(Me.TextBox1.Value) Then
  Range("Whatever").Value = Val(Me.TextBox1.Value)
  MsgBox Me.TextBox1.Value & " is not a valid number"
End If

I tried that with "IsDate" instead of "IsNumeric," but apparently that's not a real thing because it inputs the date as the number "1."  If anyone has any ideas, I'd appreciate it - thanks!


I am trying to create a custom view by editing the viewstyles.xml.  I've made a copy of one of the existing ones and I'm customizing the copy.  I have an Announcements Web Part that has 3 fields: Title, Picture (Contains a Hyperlink Picture), and Body.  Currently they are displaying like this:




I want it to display like this:


Picture | Body

I found the area that defines the fields in vwstyles.xml but I can't find where the loop begins or ends.  I'm assuming that it loops through each field in the web part and styles/places them accordingly.  Can any one help me find out where it loops or how to accomplish the new style I am trying to set up.  Thanks

I am using C# to load a url. My URL is an XML document which contains the processing instruction<?xml-Stylesheet type="text/xsl" href=".\CS_Xml_Output.xsl"?>

During development, I was successful using SHDocVw.InternetExplorer ie = new SHDocVw.InternetExplorer(); ie.Navigate2(...). But since deploying to the windows server, I am getting the error.

System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {0002DF01-0000-0000-C000-000000000046} failed due to the following error: 80070005.

Based on the advice from this forum


I tried the following alternative approaches. In both cases I am receiving the raw XML. I expect to the see the same HTML output as if viewing the document in Internet Explorer. How do I get get the transformed HTML? (NOTE: I cannot use XSLCompiledTransform because the 3rd-party provided XSL uses XSLT only supported by MSXML.)
Approach #1 using WebClient Class

client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

Stream data = client.OpenRead(xmlUrl);
StreamReader reader = new StreamReader(data);
string s = reader.ReadToEnd();

as well as
Approach #2 using HttpWebRequest Class

HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(URL.ToString());
using (HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse())
Stream receiveStream = httpResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader(receiveStream, encode);
Console.WriteLine("\r\nResponse stream received.");
Char[] read = new Char[256];
int count = readStream.Read(read, 0, 256);
while (count > 0)
String str = new String(read, 0, count);
count = readStream.Read(read, 0, 256);



hello frnds, m binding the asp.net menu from db, in db i have a column called "CategoryProduct" and i m adding this with attribute Name Text as follow:-

<xsl:attribute name="Text">
        <xsl:value-of select="Title"/>
        <xsl:text>   </xsl:text>
        <xsl:value-of select="CategoryProduct"/>

now i want is like that Title would be visible in diffrent style and CategoryProduct in diffrent style.

how this would be possible...

ur reponce would be appriciable

Thanks and Regards

Inderjeet Singh Sethi

xslt into xmlfo

Is there any way I can add CSS information with the HTML behind a Wiki page?

I wan't to make one pagethat serves as a templatesfor future posts, and I like to control the layout of this post and subsequent posts through a stylesheet.




I have few reports that are created in RS 2005. I have the asp.net page for the parameters which while running calls the report from reporting services.

Now, i want to use the same .css of the asp.net page to the reports also.

Is it possible to control the .css of the reporting services from the asp.net?

Any idea will b highly appreciated



I'm trying to put New Customized Menu at TopLink Bar of Each Page in SP 2010.

At the time of desinging I'm able to see all custom style that I have applied using custom CSS but when I brose the page not able to see any style at run time.

I'm planning to design New Interface.

Pls, forward me Good links Or Videos if you have any.



Hi Sharepoint Team,

I have the following Style in my own sharepoint page, whatever I change was reflect the change in my page except this line ==> color: #FFFFFF; <==,

I was spend the whole day to findout why this link does not reflect any change to the color of the font on my Webpart,

Any one know why, I don't want to touch my default.master page, what I want to do is I just want to overwrite the style from my default.aspx file inside the

<style type="text/css">

All overwritten style code here..



Grately appreciate your help.


.ms-WPTitle {
 border-bottom-color: #93EEAA;
 border: #93EEAA double;
 background-color: #93EEAA;
 font-weight: bold;
 font-family: Arial;
 padding-left: 6px;
 padding-right: 7px;
 padding-top: 2px;
 padding-bottom: 2px;
 font-size: 14pt;
 text-align: center;
 color: #FFFFFF;


Hi All,

Once the site is installed, what is the best way of reloading the style sheets?

We had to make last minute changes in the DefaultSite.css file and we have copied the new file on :

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\CommerceServerDefaultSiteStyles\Styles

What is the next step?

In development environment we used Share Point Designer; but, this is not available on the other servers. Is it other way of reloading the style sheets?




Hi All,

I am new to DocumentFormat.OpenXML SDK 2.0 version, since past two weeks i was trying to get proper data format into the excel sheet using code behind language as C#.Net. I was able to pass the data format by specifying the cell format type as follows:

privatevoid GenerateWorkbookStylesPart1Content(WorkbookStylesPart workbookStylesPart1)
      Stylesheet stylesheet1 = new Stylesheet();

      Fonts fonts1 = new Fonts() { Count = (UInt32Value)0U };

      Font font1 = new Font();
      FontSize fontSize1 = new FontSize() { Val = 11D };
      Color color1 = new Color() { Theme = (UInt32Value)1U };
      FontName fontName1 = new FontName() { Val = "Calibri" };
      FontFamilyNumbering fontFamilyNumbering1 = new FontFamilyNumbering() { Val = 2 };
      FontScheme fontScheme1 = new FontScheme() { Val = FontSchemeValues.Minor };



      Fills fills1 = new Fills() { Count = (UInt32Value)0U };

      Fill fill1 = new Fill();
      PatternFill patternFill1 = new PatternFill() { PatternType = PatternValues.None };


      Fill fill2 = new Fill();
      PatternFill patternFill2 = new PatternFill() { PatternType = PatternValues.Gray125 };



      Borders borders1 = new Borders() { Count = (UInt32Value)0U };

      Border border1 = new Border();
      LeftBorder leftBorder1 = new LeftBorder();
      RightBorder rightBorder1 = new RightBorder();
      TopBorder topBorder1 = new TopBorder();
      BottomBorder bottomBorder1 = new BottomBorder();
      DiagonalBorder diagonalBorder1 = new DiagonalBorder();



      CellStyleFormats cellStyleFormats1 = new CellStyleFormats() { Count = (UInt32Value)0U };
      CellFormat cellFormat1 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U };


      CellFormats cellFormats1 = new CellFormats() { Count = (UInt32Value)6U };
      CellFormat cellFormat2 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U };


      //extra code for cell formatting by Ravindranath
      CellFormat cellFormat3 = new CellFormat() { NumberFormatId = (UInt32Value)0U, FontId = (UInt32Value)1U, FillId = (UInt32Value)2U, BorderId = (UInt32Value)1U, FormatId = (UInt32Value)0U, ApplyFont = true, ApplyFill = true, ApplyBorder = true, ApplyAlignment = true };
      Alignment alignment1 = new Alignment() { Horizontal = HorizontalAlignmentValues.Left, Vertical = VerticalAlignmentValues.Center };

      CellFormat cellFormat4 = new CellFormat() { NumberFormatId = (UInt32Value)3U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true };
      CellFormat cellFormat5 = new CellFormat() { NumberFormatId = (UInt32Value)10U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true };
      CellFormat cellFormat6 = new CellFormat() { NumberFormatId = (UInt32Value)14U, FontId = (UInt32Value)0U, FillId = (UInt32Value)0U, BorderId = (UInt32Value)0U, FormatId = (UInt32Value)0U, ApplyNumberFormat = true };


      CellStyles cellStyles1 = new CellStyles() { Count = (UInt32Value)0U };
      CellStyle cellStyle1 = new CellStyle() { Name = "Normal", FormatId = (UInt32Value)0U, BuiltinId = (UInt32Value)0U };

      DifferentialFormats differentialFormats1 = new DifferentialFormats() { Count = (UInt32Value)0U };
      TableStyles tableStyles1 = new TableStyles() { Count = (UInt32Value)0U, DefaultTableStyle = "TableStyleMedium9", DefaultPivotStyle = "PivotStyleLight16" };


      workbookStylesPart1.Stylesheet = stylesheet1;

Also i did some minor change in other file i.e I have a method called WriteDataByCell which is as follows


publicvoid WriteDataByCell(IList<ExcelCellData> excelData, string sheetName)
      // Open the document for editing.using (SpreadsheetDocument document = SpreadsheetDocument.Open(docName, true))
        IEnumerable<Sheet> sheets = document.WorkbookPart.Workbook.Descendants<Sheet>().Where(s => s.Name == sheetName);
        if (sheets.Count() == 0)
          // The specified worksheet does not exist.return;
        WorksheetPart worksheetPart = GetWorksheetPartByName(document, sheetName);
        Worksheet worksheet = worksheetPart.Worksheet;
        SheetData sheetData = worksheet.GetFirstChild<SheetData>();

        SharedStringTablePart shareStringPart;
        if (document.WorkbookPart.GetPartsOfType<SharedStringTablePart>().Count() > 0)
          shareStringPart = document.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First();
          shareStringPart = document.WorkbookPart.AddNewPart<SharedStringTablePart>();

        if (excelData != null && excelData.Count > 0)
          UInt32Value cellStyleIndex = 0;
          foreach (ExcelCellData cellData in excelData)
            // int index = InsertSharedStringItem(cellData.Text, shareStringPart);
            Cell cellRange = InsertCellInWorksheet(GetColumnName(cellData.FirstCell), GetRowIndex(cellData.FirstCell), worksheetPart);

            if (cellData.FirstCell.ToString() != cellData.LastCell.ToString())
              if (cellData.Style.MergerCells)
                //Create merge cells
                CreateMergeCells(worksheet, cellData.FirstCell, cellData.LastCell);
            if (cellData.Style != null)
              //cell formatting indexes
              UInt32Value cellFillIndex = 0;
              UInt32Value cellBorderIndex = 0;
              UInt32Value cellFontIndex = 0;

              styleSheet = document.WorkbookPart.WorkbookStylesPart.Stylesheet;
              if (cellData.Style.BackgroundColor != null && cellData.Style.BackgroundColor != System.Drawing.Color.White)
                //set the background color style
                cellFillIndex = CreateFill(styleSheet, cellData.Style.BackgroundColor);
              if (cellData.Style.Borders != null)
                //set border color
                cellBorderIndex = CreateBorders(styleSheet, cellData.Style.Borders.Weight, cellData.Style.Borders.Color);
              //set font propertiesbool isBold = cellData.Style.Font.IsBold;
              bool isItalic = cellData.Style.Font.IsItalic;
              bool isStrikeThrough = cellData.Style.Font.Strikethrough;
              System.Drawing.Color fontColor;
              HorizontalAlignmentValues horizontalAlignment = cellData.Style.HorizontalAlignment;
              VerticalAlignmentValues verticalAlignment = cellData.Style.VerticalAlignment;

              if (cellData.Style.Font.Color != null)
                fontColor = cellData.Style.Font.Color;
                fontColor = System.Drawing.Color.Black;
              string fontName = string.Empty;
              if (!string.IsNullOrEmpty(cellData.Style.Font.Name))
                fontName = cellData.Style.Font.Name;
              int fontSize = cellData.Style.Font.Size;

              // Create a custom stylesheet//build the formatted header style
              cellFontIndex = CreateFont(styleSheet, fontName, fontSize, isBold, fontColor, isItalic, isStrikeThrough);
              //Create the cell styles
              cellStyleIndex = CreateCellFormat(styleSheet, cellFontIndex, cellFillIndex, cellBorderIndex, horizontalAlignment, verticalAlignment, cellData.Style.WrapText);
              //cellRange.StyleIndex = cellStyleIndex;//Currently these properties are not implemented//cellRange.Font.Subscript = cellData.Style.Font.Subscript;//cellRange.Font.Superscript = cellData.Style.Font.Superscript;//cellRange.WrapText = cellData.Style.WrapText;

            //int index = InsertSharedStringItem(cellData.Text, shareStringPart);//cellRange.CellValue = new CellValue(index.ToString());//cellRange.DataType = new EnumValue<CellValues>(CellValues.SharedString);//string cellCValue = GetCellValue(worksheetPart, shareStringPart, GetColumnName(cellData.FirstCell), GetRowIndex(cellData.FirstCell).ToString());// Code which i modified to accept data formats in the excel sheet...
            int intValue;
            //string cellValue = "";double doubleValue;
            DateTime dateValue;
            int index;
            if (double.TryParse(cellData.Text.ToString(), out doubleValue))
              cellRange.StyleIndex = 2U;
              //cellRange.StyleIndex = NumberFormatId = (UInt32Value)0U;
              cellRange.CellValue = new CellValue(doubleValue.ToString());
            elseif (int.TryParse(cellData.Text.ToString(), out intValue))
              cellRange.CellValue = new CellValue(intValue.ToString());
            elseif (DateTime.TryParse(cellData.Text.ToString(), out dateValue))
              //cellRange.StyleIndex = 4U;//DateTime d = new DateTime(1900, 1, 1);//d = d.AddDays(Int32.Parse(dateValue.ToString()) - 1);//cellValue = d.ToShortDateString();
              cellRange.CellValue = new CellValue(dateValue.ToString());
            elseif (cellData.Text.EndsWith("%"))
              string data = cellData.Text.Substring(0, cellData.Text.Length-1);
              double d;
              Double.TryParse(data, out d);
              if (cellData.Text == "0.00%" || cellData.Text == "0.00 %" || cellData.Text == "0%" || cellData.Text == "0 %" || d != 0)
                d = d / 100;
                cellRange.StyleIndex = 3U;
                cellRange.CellValue = new CellValue(d.ToString());
                index = InsertSharedStringItem(cellData.Text, shareStringPart);
                cellRange.StyleIndex = 1U;
                cellRange.CellValue = new CellValue(index.ToString());
                cellRange.DataType = new EnumValue<CellValues>(CellValues.SharedString);
              index = InsertSharedStringItem(cellData.Text, shareStringPart);
              cellRange.StyleIndex = 1U;
              cellRange.CellValue = new CellValue(index.ToString());
              cellRange.DataType = new EnumValue<CellValues>(CellValues.SharedString);

            //cellRange.DataType = new EnumValue<CellValues>(CellValues.Number);


The above block of code is written to accept the data type and write it to excel sheet.

My problem is data gets written correctly in the excel sheet but all the styles and fonts used in the sheet are messed up totally. i am not able to get to the solution why they are getting messed up. The code blocks above are according to the flow. In the second code block u can see that i am calling a foreach loop inside which i am specifying the styles for each cell data, i have two functions namely, CreateFont and CreateCellFormat over here all the things get messed up. i am pasting the two functions below.

First CreateFont

private UInt32Value CreateFont(Stylesheet styleSheet, string fontName, Nullable<double> fontSize, bool isBold, System.Drawing.Color foreColor, bool isItalic, bool isStrikeThrough)
      Font font = new Font();
      if (isItalic)
        Italic italicFont = new Italic();
        font.Italic = italicFont;
      if (!string.IsNullOrEmpty(fontName))
        FontName name = new FontName() { Val = fontName };

      if (fontSize.HasValue)
        DocumentFormat.OpenXml.Spreadsheet.FontSize size = new DocumentFormat.OpenXml.Spreadsheet.FontSize() { Val = fontSize.Value };

      if (isBold)
        Bold bold = new Bold();
      if (isStrikeThrough)
        Strike strikeThrough = new Strike();
      if (foreColor != null)
        Color color = new Color()
          Rgb = new HexBinaryValue()
            Value = System.Drawing.ColorTranslator.ToHtml(System.Drawing.Color.FromArgb(foreColor.A, foreColor.R, foreColor.G, foreColor.B)).Replace("#", "")
      UInt32Value result = styleSheet.Fonts.Count;
      return result;

The second function CreateCellFormat


private UInt32Value CreateCellFormat(Stylesheet styleSheet, UInt32Value fontIndex, UInt32Value fillIndex, UInt32Value borders, HorizontalAlignmentValues horizontalAlignment, VerticalAlignmentValues verticalAlignment, bool wrapText)
      CellFormat cellFormat = new CellFormat(new Alignment() { Horizontal = horizontalAlignment, Vertical = verticalAlignment, WrapText = wrapText });//, WrapText=true 
      if (fontIndex != null)
        cellFormat.FontId = fontIndex;
      if (fillIndex != null)
        cellFormat.FillId = fillIndex;
      if (borders != null)
        cellFormat.BorderId = borders;

      UInt32Value result = styleSheet.CellFormats.Count;
      return result;

this two functions are messing up my styles in the excel sheet.

The conclusion i came to is that the values of unsigned int are getting incremented continuously in the foreach loop of 2nd code block which i pasted.  I also created a replica of the output file in which i inserted the values manually and compared both the files with the OpneXML production tool, there i see major differences in the formats and fonts.

For example my original file shows

Fonts fonts1 = new Fonts(){ Count = (UInt32Value)7U };

My created file shows

Fonts fonts1 = new Fonts(){ Count = (UInt32Value)155U }; this is due to the loop of foreach in the second code block not able to figure out how to keep it to minimum.

Then my data formats are not consistent since i have hard coded the styleindex in the second code block, i dont know how to specify proper styleIndex to each and every cell.

I am also doubt full of Datatypes being written in the cell.

Please help me asap, any help would be appreciated.

















Dear All

I am using Master Page for my applications and i am using external Style Sheet (ie style.css).

Child pages not inherit the master page style sheet.

Please let me know how can i call the style sheet for my child pages.

Thanks and Regards




I have two conditional stylesheets referenced in the head of my master page. Because the are contained in conditional comments to show for IE6 and IE7, the relative URL to the css file isn't getting rendered correctly. Is there any way to rebase the URL within conditional comments as can be done for import css references? Current code below:

Thanks in advance!

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="xxx_web.master.cs" Inherits="website_master_xxx_web" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>xxx website</title>
<link rel="stylesheet" type="text/css" media="screen" href="../css/xxx_web_basic.css" />
<link rel="stylesheet" type="text/css" media="screen" href="../css/xxx_web_structure.css" />
<!--[if lte IE 6]>
 <link rel="stylesheet" type="text/css" media="screen" href="../css/xxx_web_ie6.css" />
<!--[if lte IE 7]>
 <link rel="stylesheet" type="text/css" media="screen" href="../css/xxx_web_ie7.css" />


Hi All,

does anybody know the method www.w3.org has used to switch style sheets when you alter your browser (make your browser smaller and it will switch to a different css)?  i can't see no javascript being used?  

I have applied a style sheet through my entire site collection, however when I click on  View All site content on any site it reverts to the classic theme out of the box.
I have a content page that has application.master as its masterpagefile. In the content page, I have inserted an iframe that calls a web page, which has its own CSS style-sheets. The styles in the iframed web page does not applied correctly in the content page although it is working perfectly when I render the web page outside the content page. It also works ok with "Page Viewer Web Part".

For the sake of testing, I removed
from application.master. The content page renders with no style but the styles in the iframed web page still looks as bad.

I'm guessing there could be some kind of conflicts of style-sheets. Am I missing something here?


Hi all,

I am trying to set the width of the quick launch bar to 200px using style sheet. Can anyone tell me how can we set the width of the quick launch bar to 200px using style sheet.


Hi ,

I want to change my page css using my custom css.can anyone tell me where i can put the css and how can i map it in the master page..



<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure