|
|
Hi,
how can open office be used in .net web/windows application for converting excel to pdf
Thanks
|
|
|
|
|
|
Why do you need to use open office to create a PDF?
There are plenty of PDF libraries that you can use from your app and when I did a search, there's someone who has already done what you need. It's called ExcelReports[^].
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I am developing an application in .NET to solve VRP, without using ArcGIS Server, but I can not find a complete sample code, I used other samples such as routesolver and get help from them, but I faced Exception in INASolver.Solve that shows I didn't load NAClasses correctly, I will be really thankfull if you could help me.Please!!!
I get COMExecption on the line : INASolver.Solve(...), details:Invalid input in NAClass
my code:
IAoInitialize pAoInitialize = new AoInitializeClass();
pAoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcView);
pAoInitialize.CheckOutExtension(esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork);
IWorkspaceFactory ipWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
m_pWorkspace = ipWorkspaceFactory.OpenFromFile(SHAPE_WORKSPACE, 0);
IFeatureWorkspace pFWorkspace = m_pWorkspace as IFeatureWorkspace;
IWorkspaceExtensionManager pWorkspaceExtensionManager = m_pWorkspace as IWorkspaceExtensionManager;
UID pUID = new UIDClass();
pUID.Value = "esriGeoDatabase.NetworkDatasetWorkspaceExtension";
IDatasetContainer2 pDatasetContainer2;
pDatasetContainer2 = pWorkspaceExtensionManager.FindExtension(pUID) as IDatasetContainer2;
m_pNetworkDataset = pDatasetContainer2.get_DatasetByName(esriDatasetType.esriDTNetworkDataset, NETWORK_DATASET) as INetworkDataset;
INALayer pNALayer = CreateVRPAnalysisLayer("Vehicle Routing Problem", m_pNetworkDataset);
String INPUT_DEPOTS = "DistributionCenters";
String INPUT_ORDERS = "Stores";
INAContext pNAContext;
pNAContext = pNALayer.Context;
INAContextEdit vrpNAContextEdit = pNAContext as INAContextEdit;
vrpNAContextEdit.Bind(pNALayer.Context.NetworkDataset, null);
m_pInputFClass = pFWorkspace.OpenFeatureClass(INPUT_DEPOTS);
ICursor InputDepotsCursor = m_pInputFClass.Search(new QueryFilterClass(), false) as ICursor;
LoadAnalysisLayer("Depots", pNAContext, InputDepotsCursor);
m_pInputFClass = pFWorkspace.OpenFeatureClass(INPUT_ORDERS);
ICursor InputOrdersCursor = m_pInputFClass.Search(new QueryFilterClass(), false) as ICursor;
LoadAnalysisLayer("Orders", pNAContext, InputOrdersCursor);
IMap vrpMap = axMapControl1.Map;
ITable routesInputTable = GetStandaloneTable("Vehicles", vrpMap).Table;
ICursor InputRoutesCursor = routesInputTable.Search(new QueryFilterClass(), true) as ICursor;
LoadAnalysisLayer("Routes", pNAContext, InputRoutesCursor);
INASolver pSolver;
pSolver = pNAContext.Solver;
INAVRPSolver vrpSolver = pSolver as INAVRPSolver;
vrpSolver.GenerateInternalRouteContext = true;
vrpSolver.DefaultDate = DateTime.Today;
pSolver.Solve(pNAContext, new GPMessagesClass(), new CancelTrackerClass());
private void LoadAnalysisLayer(string ClassName, INAContext context, ICursor cursor)
{
INAClass pNAClass;
pNAClass = context.NAClasses.get_ItemByName(ClassName) as INAClass;
INAClassFieldMap pNAClassFieldMap = new NAClassFieldMapClass();
pNAClassFieldMap.set_MappedField("Name", SHAPE_INPUT_NAME_FIELD);
INAClassLoader pNALoader = new NAClassLoaderClass();
pNALoader.Locator = context.Locator;
pNALoader.NAClass = pNAClass;
pNALoader.FieldMap = pNAClassFieldMap;
int rowsInCursor = 0;
int rowsLocated = 0;
pNALoader.Load(cursor, new CancelTrackerClass(), ref rowsInCursor, ref rowsLocated);
}
|
|
|
|
|
I know the part that I get standalone table is wrong, because I don't have any table named vehicles in my map, but I don't now how to add routes, and there is no sample code, please help!!
|
|
|
|
|
line = "==XXXT08746=05/01/09 15:13 112 4 IT 0:01'22 0 #2 ";
string Duration = line.Substring(64, 9).Replace("#","[#]");
int s = Convert.ToInt32(Duration.Substring(1, 2));
int s = Convert.ToInt32(Duration.Substring(1, 2));
int y = Convert.ToInt32(Duration.Substring(3, 2));
int l = Convert.ToInt32(Duration.Substring(6, 2));
int NDura = s + y + l;
---->>>> Error System.FormatException: Input string was not in a correct format.
So what should I do with this ?
|
|
|
|
|
This is very silly mistake which u can trace it out.
yueru wrote: int s = Convert.ToInt32(Duration.Substring(1, 2));
int s = Convert.ToInt32(Duration.Substring(1, 2));
int y = Convert.ToInt32(Duration.Substring(3, 2));
int l = Convert.ToInt32(Duration.Substring(6, 2));
In above four lines, check wat is the value of (Duration.Substring());
it may be null or may not be in format to convert to integer.
|
|
|
|
|
Int32.Parse(String)
battulga
|
|
|
|
|
yueru wrote: int s = Convert.ToInt32(Duration.Substring(1, 2));
int s = Convert.ToInt32(Duration.Substring(1, 2));
I don't understand how the code has got compiled!
yueru wrote: So what should I do with this ?
Submit it to Microsoft critical bugs department
yueru wrote: Error System.FormatException: Input string was not in a correct format.
Finally what is the value you are expecting in the
Duration string ? Do the debug and verify if it has the desired value or not...
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
|
|
|
|
|
The quick answer:
int s = Convert.ToInt32(Duration.Substring(1, 1));
Why?
Try changing your code to this:
String line = "==XXXT08746=05/01/09 15:13 112 4 IT 0:01'22 0 #2 ";
string Duration = line.Substring(64, 9).Replace("#", "[#]");
string a = Duration.Substring(1, 2);
string b = Duration.Substring(3, 2);
string c = Duration.Substring(6, 2);
int s = Convert.ToInt32(a);
int y = Convert.ToInt32(b);
int l = Convert.ToInt32(c);
int NDura = s + y + l;
You will discover that duration equals " 0:01'22 " and so the string you are trying to parse is "0:" - thats why you keep getting the error.
Also this line:
string Duration = line.Substring(64, 9).Replace("#", "[#]");
Is kind of wierd as the Replace has no effect - as I mentioned Duration == " 0:01'22 ". No "#" there...
|
|
|
|
|
Thank you
I 've got it even if I've made alot of mistake like u said
now is my code
string Duration = line.Replace("'", "[']");
string LineOO = line.Replace("#", "[#]");
string Date = line.Substring(12, 8);
if (line.Substring(11, 1) == "=")
{
string Time = line.Substring(21, 5);
string Linein = line.Substring(27, 10);
string Lineout = LineOO.Substring(38, 1);
if ((string.Compare(Lineout, "0") > 0 || string.Compare(Lineout, "0") == 0) && (string.Compare(Lineout, "9") < 0 || string.Compare(Lineout, "9") == 0))
{
string Number = line.Substring(40, 20);
string Status = line.Substring(61, 3);
string NDuration = Duration.Substring(64, 10);
string b = NDuration.Substring(3, 2);
string c = NDuration.Substring(6, 2);
int y = Convert.ToInt32(b);
int l = Convert.ToInt32(c);
int NDura = y + l;
string Cost = line.Substring(75, 3);
string Detail = line.Substring(79, 2);
string Network = line.Substring(82, 8);
and it work
Thx
|
|
|
|
|
There is still room for some improvement.
Instead of getting a one character string, you can get a character. You can change this:
if (line.Substring(11, 1) == "=")
to:
if (line[11] == '=')
You can use the >= operator instead of doing both > and == comparisons. You can change this:
if ((string.Compare(Lineout, "0") > 0 || string.Compare(Lineout, "0") == 0) && (string.Compare(Lineout, "9") < 0 || string.Compare(Lineout, "9") == 0))
to:
if (string.Compare(Lineout, "0") >= 0 && string.Compare(Lineout, "9") <= 0)
However, you can use a char instead of a one character string there too:
char Lineout = Line00[38];
if (Lineout >= '0' && Lineout <= '9')
or simply:
if (Char.IsDigit(Line00, 38))
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Wowwww
It's so short and simply but I've never knoww.
thx very much
Code is ok but I 've just want to know how to decrease time to do it coz I have 10,100 data and it took a long time.
|
|
|
|
|
I while back I wrote this method that you can use to replace Int32.Parse, and that is about ten times faster. That could help to speed up it a bit.
public static int ParseInt32(string text) {
long value = 0;
long sign = 1;
bool first = true;
foreach (char c in text) {
if (c >= '0' && c <= '9') {
value = value * 10 + c - '0';
} else if (c == '-' && first) {
sign = -1;
} else {
throw new FormatException();
}
first = false;
}
value *= sign;
if (value < int.MinValue || value > int.MaxValue) throw new OverflowException();
return (int)value;
}
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i need to get customer information from a java web service my client app is a C# . instead of calling the web service several times i want to get customer object , to do this i use a customer xsd and generated two classes one for c# and other of java ,then i added those classes to relevant party, in the java web service i create a customer object and fill it with info and send to c#, but in C3 it say that the passed object can't be implicitly cast ,any idea to solve this .
|
|
|
|
|
Whenever you modify the java code you need to update the references(proxy classes) in C# and then compile it.
I don't understand your problem exactly but hope this helps you.
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
|
|
|
|
|
I have my form currently set up with a treeview and a listview. The treeview shows all the folders with check boxes and the listview shows the files within the selected folder on the treeview.
I am trying to create a backup program which can successfully backup selected files/folders and successfully restore these at a later time.
My question is if anyone can give me any ideas on how to approach this? I'm thinking I would use an output textfile showing which files/folders were backed up and their fullpath?
|
|
|
|
|
Hi,
How do i select the whole listViewItem line (all the subitems of an item) when trying to copy it in the clipboard?
I have a listView with 5 columns. When i try to select 1 row it only selects the first column value not the whole row..
any ideas?
Regards,
Alex
“Be the change you want to see in the world.”
|
|
|
|
|
Assuming this is a Windows Forms ListView.
I don't know if it will make any difference to a drag-drop operation, but ListView has a FullRowSelect property, which er... well it does what it says on the tin.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Set the FullRowSelect property to true.
for example,
listView1.FullRowSelect = true;
|
|
|
|
|
Check the properties.
listView1.FullRowSelect = true;
|
|
|
|
|
Hi people,
I have the a form in my application where the user can enter a data and time and then save it to a Mysql database. but I get a FormatExeption saying "Input string was not in a correct format" How can I convert from .net datatime datatype to Mysql database type ?
Heres my method for inserting a row that contains a datetime datatype
private void shiftInsertNewRow()
{
conn = new MySqlConnection
("datasource=localhost;username=admin;password=student;database=hospital");
conn.Open();
MySqlCommand command = new MySqlCommand
("insert into shifts(ShiftID, Starttime, Endtime, WardID, NurseID) select ?ShiftID, ?Starttime, ?Endtime, ?WardID, ?NurseID", conn);
command.Parameters.Add(new MySqlParameter("?ShiftID", MySqlDbType.Int32));
command.Parameters.Add(new MySqlParameter("?Starttime", MySqlDbType.Datetime));
command.Parameters.Add(new MySqlParameter("?Endtime", MySqlDbType.Datetime));
command.Parameters.Add(new MySqlParameter("?WardID", MySqlDbType.Int32));
command.Parameters.Add(new MySqlParameter("?NurseID", MySqlDbType.Int32));
command.Parameters[0].Value = shiftidTextBox.Text;
command.Parameters[1].Value = startTimeTextBox.Text;
command.Parameters[2].Value = endTimTextBox.Text;
command.Parameters[3].Value = wardShiftidTextBox.Text;
command.Parameters[4].Value = wardNameTextBox.Text;
command.ExecuteNonQuery();
conn.Close();
}
any help would be greatly appreciated
|
|
|
|
|
I would imaging it would work the same was as SQL Server. Convert the text to a DateTime object, then pass the DateTime object as a parameter.
Man who stand on hill with mouth open wait long time for roast duck to drop in
|
|
|
|
|
well I tried to assign a DateTime object to Value but it didnt work either
command.Parameters[1].Value = DateTime.Now;
command.Parameters[2].Value = DateTime.Now;
|
|
|
|
|